Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |
java.lang.Object | +----java.awt.swing.KeyStroke
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 KeyTyped 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.
All KeyStroke objects are cached. To get one, use getKeyStroke
.
Warning: serialized objects of this class will not be compatible with future swing releases. The current serialization support is appropriate for short term storage or RMI between Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.
Method Summary | |
boolean | equals(Object anObject)
|
char | getKeyChar()
|
int | getKeyCode()
|
static KeyStroke | getKeyStroke(char keyChar)
|
static KeyStroke | getKeyStroke(char keyChar,
boolean onKeyRelease)
|
static KeyStroke | getKeyStroke(int keyCode,
int modifiers,
boolean onKeyRelease)
|
static KeyStroke | getKeyStroke(int keyCode,
int modifiers)
|
static KeyStroke | getKeyStroke(String representation)
|
static KeyStroke | getKeyStrokeForEvent(KeyEvent anEvent)
|
int | getModifiers()
|
int | hashCode()
|
boolean | isOnKeyRelease()
|
String | toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static KeyStroke getKeyStroke(char keyChar)
keyChar
- the character value for a keyboard key
public static KeyStroke getKeyStroke(char keyChar, boolean onKeyRelease)
keyChar
- the character value for a keyboard key
onKeyRelease
- a boolean value. When true, specifies that
the key is active when it is released.
public static KeyStroke getKeyStroke(int keyCode, int modifiers, boolean onKeyRelease)
The modifiers consist of any combination of:
keyChar
- the character value for a keyboard key
modifiers
- an int specifying any combination of the key modifiers.
onKeyRelease
- a boolean value. When true, specifies that
the key is active when it is released.
public static KeyStroke getKeyStroke(int keyCode, int modifiers)
The modifiers consist of any combination of:
keyChar
- the character value for a keyboard key
modifiers
- an int specifying any combination of the key modifiers.
public static KeyStroke getKeyStrokeForEvent(KeyEvent anEvent)
This method obtains the keyChar from a KeyTyped event, and the keyCode from a KeyPressed or KeyReleased event, so you don't have to.
anEvent
- the KeyEvent to obtain the KeyStroke from
public static KeyStroke getKeyStroke(String representation)
representation
- a String specifying a KeyStroke
public char getKeyChar()
public int getKeyCode()
public int getModifiers()
public boolean isOnKeyRelease()
public int hashCode()
public boolean equals(Object anObject)
anObject
- the Object to compare this object to
public String toString()
Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |