TestApplet.java revision 6883:be89273ceb9c
1178476Sjb/* 2178476Sjb * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 3178476Sjb * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4178476Sjb * 5178476Sjb * This code is free software; you can redistribute it and/or modify it 6178476Sjb * under the terms of the GNU General Public License version 2 only, as 7178476Sjb * published by the Free Software Foundation. 8178476Sjb * 9178476Sjb * This code is distributed in the hope that it will be useful, but WITHOUT 10178476Sjb * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11178476Sjb * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12178476Sjb * version 2 for more details (a copy is included in the LICENSE file that 13178476Sjb * accompanied this code). 14178476Sjb * 15178476Sjb * You should have received a copy of the GNU General Public License version 16178476Sjb * 2 along with this work; if not, write to the Free Software Foundation, 17178476Sjb * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18178476Sjb * 19178476Sjb * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20178476Sjb * or visit www.oracle.com if you need additional information or have any 21178476Sjb * questions. 22178476Sjb */ 23178476Sjb 24178476Sjbimport javax.swing.*; 25178476Sjbimport java.awt.*; 26178476Sjbimport java.awt.Color; 27178476Sjbimport java.awt.Label; 28178476Sjbimport java.awt.TextArea; 29178476Sjbimport java.awt.event.KeyAdapter; 30178476Sjbimport java.awt.event.KeyEvent; 31178534Sjbimport java.lang.String; 32178534Sjbimport java.lang.System; 33178534Sjb 34178534Sjb 35178476Sjbpublic class TestApplet extends JApplet { 36178476Sjb 37178476Sjb public void init() { 38178534Sjb final TextArea log = new TextArea("Events:\n"); 39178534Sjb log.setEditable(false); 40178534Sjb log.setSize(400, 200); 41178534Sjb this.add(log); 42178476Sjb log.addKeyListener( 43178476Sjb new KeyAdapter() { 44178476Sjb @Override public void keyTyped(KeyEvent e) { 45178476Sjb log.append("Key typed: char = " + e.getKeyChar() + "\n"); 46178476Sjb } 47178476Sjb 48178476Sjb @Override public void keyPressed(KeyEvent e) { 49178476Sjb log.append("Key pressed: char = " + e.getKeyChar() + " code = " + e.getKeyCode() + "\n"); 50178476Sjb } 51178476Sjb 52178476Sjb @Override public void keyReleased(KeyEvent e) { 53178476Sjb log.append("Key released: char = " + e.getKeyChar() + " code = " + e.getKeyCode() + "\n"); 54178476Sjb } 55178476Sjb }); 56178476Sjb } 57178476Sjb 58178476Sjb public void start() { 59 } 60 61 public void stop() { 62 } 63 64 public void destroy() { 65 } 66 67} 68