Additional top-level class in compilation unit: VKCollection.
AWTKeyStroke represents a key action on the
keyboard, or equivalent input device. AWTKeyStrokes
can correspond to only a press or release of a
particular key, just as KEY_PRESSED and
KEY_RELEASED KeyEvents do;
alternately, they can correspond to typing a specific Java character, just
as KEY_TYPED KeyEvents do.
In all cases, AWTKeyStrokes can specify modifiers
(alt, shift, control, meta, altGraph, or a combination thereof) which must be present
during the action for an exact match.
AWTKeyStrokes are immutable, and are intended
to be unique. Client code should never create an
AWTKeyStroke on its own, but should instead use
a variant of getAWTKeyStroke. Client use of these factory
methods allows the AWTKeyStroke implementation
to cache and share instances efficiently.
getAWTKeyStroke
| Modifier and Type | Field and Description |
|---|---|
| private static Map | |
| private static AWTKeyStroke | |
| private char | |
| private int | |
| private static Map | |
| private int | |
| private boolean | |
| private static final long | serialVersionUID
Use serialVersionUID from JDK 1.4 for interoperability. |
| private static VKCollection | vks
Associates VK_XXX (as a String) with code (as Integer). |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected | AWTKeyStroke(char
the character value for a keyboard key keyChar, int the key code for this keyCode, int AWTKeyStrokea bitwise-ored combination of any modifiers modifiers, boolean true if this
AWTKeyStroke corresponds
to a key release; false otherwiseConstructs an |
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | Returns: true if the objects are identicalthe Object to compare this object to anObject)Overrides java. Returns true if this object is identical to the specified object. |
| public static AWTKeyStroke | Returns: anAWTKeyStroke object for that keythe character value for a keyboard key keyChar)Returns a shared instance of an |
| public static AWTKeyStroke | Returns: anAWTKeyStroke object for that keythe Character object for a keyboard character keyChar, int a bitwise-ored combination of any modifiers modifiers)Returns a shared instance of an |
| public static AWTKeyStroke | Returns: an AWTKeyStroke object for that keyan int specifying the numeric code for a keyboard key keyCode, int a bitwise-ored combination of any modifiers modifiers, boolean true if the AWTKeyStroke
should represent a key release; false otherwiseReturns a shared instance of an |
| public static AWTKeyStroke | Returns: anAWTKeyStroke object for that keyan int specifying the numeric code for a keyboard key keyCode, int a bitwise-ored combination of any modifiers modifiers)Returns a shared instance of an |
| public static AWTKeyStroke | Returns: anAWTKeyStroke object for that Stringa String formatted as described above s)Parses a string and returns an |
| public static AWTKeyStroke | Returns: theAWTKeyStroke that precipitated the eventthe anEvent)KeyEvent from which to
obtain the AWTKeyStrokeReturns an |
| private static synchronized AWTKeyStroke | |
| public final char | |
| public final int | Returns: an int containing the key code valueReturns the numeric key code for this |
| public final int | Returns: KeyEvent.KEY_PRESSED,
KeyEvent.KEY_TYPED,
or KeyEvent.KEY_RELEASEDReturns the type of |
| public final int | Returns: an int containing the modifiersReturns the modifier keys for this |
| pack-priv static String | |
| private static VKCollection | |
| pack-priv static String | |
| private static int | |
| public int | Returns: an int that represents this objectOverrides java. Returns a numeric value for this object that is likely to be unique, making it a good choice as the index value in a hash table. |
| public final boolean | Returns: true if this AWTKeyStroke
represents a key release; false otherwiseReturns whether this |
| private static int | |
| private static int | |
| protected Object | Returns: a cached instance which is equal to this instanceReturns a cached instance of |
| protected static void | registerSubclass(Class<?>
the new Class of which the factory methods should create
instances subclass)
Deprecated
The method has no effect and is only left present to avoid introducing a binary incompatibility. |
| public String | Returns: a String representation of this objectOverrides java. Returns a string that displays and identifies this object's properties. |
| cache | back to summary |
|---|---|
| private static Map<AWTKeyStroke, AWTKeyStroke> cache | |
| cacheKey | back to summary |
|---|---|
| private static AWTKeyStroke cacheKey | |
| keyChar | back to summary |
|---|---|
| private char keyChar | |
| keyCode | back to summary |
|---|---|
| private int keyCode | |
| modifierKeywords | back to summary |
|---|---|
| private static Map<String, Integer> modifierKeywords | |
| modifiers | back to summary |
|---|---|
| private int modifiers | |
| onKeyRelease | back to summary |
|---|---|
| private boolean onKeyRelease | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Use serialVersionUID from JDK 1.4 for interoperability. | |
| vks | back to summary |
|---|---|
| private static VKCollection vks Associates VK_XXX (as a String) with code (as Integer). This is done to avoid the overhead of the reflective call to find the constant. | |
| AWTKeyStroke | back to summary | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| protected AWTKeyStroke() Constructs an
AWTKeyStrokes should not be constructed
by client code. Use a variant of getAWTKeyStroke
instead.
| |||||||||||
| AWTKeyStroke | back to summary |
|---|---|
| protected AWTKeyStroke(char keyChar, int keyCode, int modifiers, boolean onKeyRelease) Constructs an
| |
| equals | back to summary |
|---|---|
| public final boolean equals(Object anObject) Overrides java. Returns true if this object is identical to the specified object.
| |
| getAWTKeyStroke | back to summary |
|---|---|
| public static AWTKeyStroke getAWTKeyStroke(char keyChar) Returns a shared instance of an
| |
| getAWTKeyStroke | back to summary |
|---|---|
| public static AWTKeyStroke getAWTKeyStroke(Character keyChar, int modifiers) Returns a shared instance of an
| |
| getAWTKeyStroke | back to summary |
|---|---|
| public static AWTKeyStroke getAWTKeyStroke(int keyCode, int modifiers, boolean onKeyRelease) Returns a shared instance of an
The "virtual key" constants defined in
java.awt.event.KeyEvent.getExtendedKeyCodeForChar.
The modifiers consist of any combination of:
| |
| getAWTKeyStroke | back to summary |
|---|---|
| public static AWTKeyStroke getAWTKeyStroke(int keyCode, int modifiers) Returns a shared instance of an
The "virtual key" constants defined in
| |
| getAWTKeyStroke | back to summary |
|---|---|
| public static AWTKeyStroke getAWTKeyStroke(String s) Parses a string and returns an <modifiers>* (<typedID> | <pressedReleasedID>) modifiers := shift | control | ctrl | meta | alt | altGraph typedID := typed <typedKey> typedKey := string of length 1 giving Unicode character. pressedReleasedID := (pressed | released) key key := KeyEvent key code name, i.e. the name following "VK_".If typed, pressed or released is not specified, pressed is assumed. Here are some examples:
"INSERT" => getAWTKeyStroke(KeyEvent.VK_INSERT, 0);
"control DELETE" => getAWTKeyStroke(KeyEvent.VK_DELETE, InputEvent.CTRL_MASK);
"alt shift X" => getAWTKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK);
"alt shift released X" => getAWTKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK, true);
"typed a" => getAWTKeyStroke('a');
| |
| getAWTKeyStrokeForEvent | back to summary |
|---|---|
| public static AWTKeyStroke getAWTKeyStrokeForEvent(KeyEvent anEvent) Returns an
This method obtains the keyChar from a
| |
| getCachedStroke | back to summary |
|---|---|
| private static synchronized AWTKeyStroke getCachedStroke(char keyChar, int keyCode, int modifiers, boolean onKeyRelease) | |
| getKeyChar | back to summary |
|---|---|
| public final char getKeyChar() Returns the character for this
| |
| getKeyCode | back to summary |
|---|---|
| public final int getKeyCode() Returns the numeric key code for this
| |
| getKeyEventType | back to summary |
|---|---|
| public final int getKeyEventType() Returns the type of
| |
| getModifiers | back to summary |
|---|---|
| public final int getModifiers() Returns the modifier keys for this
| |
| getModifiersText | back to summary |
|---|---|
| pack-priv static String getModifiersText(int modifiers) | |
| getVKCollection | back to summary |
|---|---|
| private static VKCollection getVKCollection() | |
| getVKText | back to summary |
|---|---|
| pack-priv static String getVKText(int keyCode) | |
| getVKValue | back to summary |
|---|---|
| private static int getVKValue(String key) Returns the integer constant for the KeyEvent.VK field named
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns a numeric value for this object that is likely to be unique, making it a good choice as the index value in a hash table.
| |
| isOnKeyRelease | back to summary |
|---|---|
| public final boolean isOnKeyRelease() Returns whether this
| |
| mapNewModifiers | back to summary |
|---|---|
private static int mapNewModifiers(int modifiers)
| |
| mapOldModifiers | back to summary |
|---|---|
private static int mapOldModifiers(int modifiers)
| |
| readResolve | back to summary |
|---|---|
| protected Object readResolve() throws ObjectStreamException Returns a cached instance of
| |
| registerSubclass | back to summary |
|---|---|
| protected static void registerSubclass(Class<?> subclass)
Deprecated
The method has no effect and is only left present to avoid introducing a binary incompatibility.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string that displays and identifies this object's properties.
The
| |