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
equals(Object)
- Compares two Objects for equality.
getKeyChar()
-
getKeyCode()
-
getKeyStroke(char)
- Return a shared instance of a key stroke given a char code
getKeyStroke(int, int)
-
getKeyStroke(int, int, boolean)
- Return a shared instance of a key stroke given a char code and a modifier
getKeyStroke(String)
- Return a shared instance of a key stroke matching a string representation
getKeyStrokeForEvent(KeyEvent)
- Return a keystroke from an event.
getModifiers()
-
hashCode()
- Returns a hash code value for the object.
isOnKeyRelease()
-
getKeyStroke
public static KeyStroke getKeyStroke(char keyChar)
- Return a shared instance of a key stroke given a char code
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
getKeyStroke
public static KeyStroke getKeyStroke(int keyCode,
int modifiers)
getKeyStrokeForEvent
public static KeyStroke getKeyStrokeForEvent(KeyEvent anEvent)
- Return a keystroke from an event. Use the the keyChar if present, keyCode otherwise
getKeyStroke
public static KeyStroke getKeyStroke(String representation)
- Return a shared instance of a key stroke matching a string representation
getKeyChar
public char getKeyChar()
getKeyCode
public int getKeyCode()
getModifiers
public int getModifiers()
isOnKeyRelease
public boolean isOnKeyRelease()
hashCode
public int hashCode()
- Returns a hash code value for the object.
- Overrides:
- hashCode in class Object
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