1 /* 2 * @(#)KeyAdapter.java 1.17 03/12/19 3 * 4 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 5 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 */ 7 8 package java.awt.event; 9 10 /** 11 * An abstract adapter class for receiving keyboard events. 12 * The methods in this class are empty. This class exists as 13 * convenience for creating listener objects. 14 * <P> 15 * Extend this class to create a <code>KeyEvent</code> listener 16 * and override the methods for the events of interest. (If you implement the 17 * <code>KeyListener</code> interface, you have to define all of 18 * the methods in it. This abstract class defines null methods for them 19 * all, so you can only have to define methods for events you care about.) 20 * <P> 21 * Create a listener object using the extended class and then register it with 22 * a component using the component's <code>addKeyListener</code> 23 * method. When a key is pressed, released, or typed, 24 * the relevant method in the listener object is invoked, 25 * and the <code>KeyEvent</code> is passed to it. 26 * 27 * @author Carl Quinn 28 * @version 1.17 12/19/03 29 * 30 * @see KeyEvent 31 * @see KeyListener 32 * @see <a HREF="http://java.sun.com/docs/books/tutorial/post1.0/ui/keylistener.html">Tutorial: Writing a Key Listener</a> 33 * @see <a HREF="http://www.awl.com/cp/javaseries/jcl1_2.html">Reference: The Java Class Libraries (update file)</a> 34 * 35 * @since 1.1 36 */ 37 public abstract class KeyAdapter implements KeyListener { 38 /** 39 * Invoked when a key has been typed. 40 * This event occurs when a key press is followed by a key release. 41 */ 42 public void keyTyped(KeyEvent e) {} 43 44 /** 45 * Invoked when a key has been pressed. 46 */ 47 public void keyPressed(KeyEvent e) {} 48 49 /** 50 * Invoked when a key has been released. 51 */ 52 public void keyReleased(KeyEvent e) {} 53 } 54