APIdia Launch Partner
Top Description Constructors Methods
java.awt.event

public abstract Class KeyAdapter

extends Object
implements KeyListener
Class Inheritance
All Implemented Interfaces
java.awt.event.KeyListener, java.util.EventListener
Known Direct Subclasses
javax.swing.ToolTipManager.AccessibilityKeyListener, javax.swing.colorchooser.DefaultSwatchChooserPanel.RecentSwatchKeyListener, javax.swing.colorchooser.DefaultSwatchChooserPanel.MainSwatchKeyListener, javax.swing.plaf.basic.BasicComboBoxUI.KeyHandler, javax.swing.plaf.basic.BasicComboPopup.InvocationKeyHandler, javax.swing.plaf.basic.BasicTreeUI.KeyHandler

An abstract adapter class for receiving keyboard events. The methods in this class are empty. This class exists as convenience for creating listener objects.

Extend this class to create a KeyEvent listener and override the methods for the events of interest. (If you implement the KeyListener interface, you have to define all of the methods in it. This abstract class defines null methods for them all, so you can only have to define methods for events you care about.)

Create a listener object using the extended class and then register it with a component using the component's addKeyListener method. When a key is pressed, released, or typed, the relevant method in the listener object is invoked, and the KeyEvent is passed to it.

Author
Carl Quinn
Since
1.1
See Also
KeyEvent, KeyListener, Tutorial: Writing a Key Listener

Constructor Summary

AccessConstructor and Description
protected
KeyAdapter()

Constructs a KeyAdapter.

Method Summary

Modifier and TypeMethod and Description
public void
keyPressed(KeyEvent e)

Implements java.awt.event.KeyListener.keyPressed.

Invoked when a key has been pressed.

public void
keyReleased(KeyEvent e)

Implements java.awt.event.KeyListener.keyReleased.

Invoked when a key has been released.

public void
keyTyped(KeyEvent e)

Implements java.awt.event.KeyListener.keyTyped.

Invoked when a key has been typed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

KeyAdapterback to summary
protected KeyAdapter()

Constructs a KeyAdapter.

Method Detail

keyPressedback to summary
public void keyPressed(KeyEvent e)

Implements java.awt.event.KeyListener.keyPressed.

Invoked when a key has been pressed.

keyReleasedback to summary
public void keyReleased(KeyEvent e)

Implements java.awt.event.KeyListener.keyReleased.

Invoked when a key has been released.

keyTypedback to summary
public void keyTyped(KeyEvent e)

Implements java.awt.event.KeyListener.keyTyped.

Invoked when a key has been typed. This event occurs when a key press is followed by a key release.