All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class java.awt.swing.KeyStroke

java.lang.Object
    |
    +----java.awt.swing.KeyStroke

public class KeyStroke
extends Object
implements Serializable
A KeyStroke instance represents a key being typed on the keyboard -- it contains both a char code for the key and a modifier (alt, shift, ctrl, meta, or a combination).

KeyStroke objects are used to define high-level (semantic) action events. Instead of trapping every keystroke and throwing away the ones you are not interested in, those keystrokes you care about automatically initiate actions on the components they are registered with.

KeyStroke objects handle both character-code generating keystrokes you would trap with a KeyClicked event handler and key-code generating keystrokes (like Enter or F1) that you would trap with a KeyPressed event handler.

KeyStroke objects are immutable and unique.

See Also:
registerKeyboardAction

Method Index

 o equals(Object)
Compares two Objects for equality.
 o getKeyChar()
 o getKeyCode()
 o getKeyStroke(char)
Return a shared instance of a key stroke given a char code
 o getKeyStroke(int, int)
 o getKeyStroke(int, int, boolean)
Return a shared instance of a key stroke given a char code and a modifier
 o getKeyStroke(String)
Return a shared instance of a key stroke matching a string representation
 o getKeyStrokeForEvent(KeyEvent)
Return a keystroke from an event.
 o getModifiers()
 o hashCode()
Returns a hash code value for the object.
 o isOnKeyRelease()

Methods

 o getKeyStroke
public static KeyStroke getKeyStroke(char keyChar)
Return a shared instance of a key stroke given a char code

 o getKeyStroke
public static KeyStroke getKeyStroke(int keyCode,
                                     int modifiers,
                                     boolean onKeyRelease)
Return a shared instance of a key stroke given a char code and a modifier

 o getKeyStroke
public static KeyStroke getKeyStroke(int keyCode,
                                     int modifiers)
 o getKeyStrokeForEvent
public static KeyStroke getKeyStrokeForEvent(KeyEvent anEvent)
Return a keystroke from an event. Use the the keyChar if present, keyCode otherwise

 o getKeyStroke
public static KeyStroke getKeyStroke(String representation)
Return a shared instance of a key stroke matching a string representation

 o getKeyChar
public char getKeyChar()
 o getKeyCode
public int getKeyCode()
 o getModifiers
public int getModifiers()
 o isOnKeyRelease
public boolean isOnKeyRelease()
 o hashCode
public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class Object
 o equals
public boolean equals(Object anObject)
Compares two Objects for equality.

Overrides:
equals in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Submit a bug or feature