public final class KeyCharacterCombination extends KeyCombination
KeyCombination.Modifier, KeyCombination.ModifierValue
ALT_ANY, ALT_DOWN, CONTROL_ANY, CONTROL_DOWN, META_ANY, META_DOWN, SHIFT_ANY, SHIFT_DOWN, SHORTCUT_ANY, SHORTCUT_DOWN
Constructor and Description |
---|
KeyCharacterCombination(java.lang.String character,
KeyCombination.Modifier... modifiers)
Constructs a
KeyCharacterCombination for the specified main key
character and the specified list of modifiers. |
KeyCharacterCombination(java.lang.String character,
KeyCombination.ModifierValue shift,
KeyCombination.ModifierValue control,
KeyCombination.ModifierValue alt,
KeyCombination.ModifierValue meta,
KeyCombination.ModifierValue shortcut)
Constructs a
KeyCharacterCombination for the specified main key
character and with an explicit specification of all modifier keys. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Tests whether this
KeyCharacterCombination equals to the
specified object. |
java.lang.String |
getCharacter()
Gets the key character associated with this key combination.
|
java.lang.String |
getName()
Returns a string representation of this
KeyCharacterCombination . |
int |
hashCode()
Returns a hash code value for this
KeyCharacterCombination . |
boolean |
match(KeyEvent event)
Tests whether this key combination matches the key combination in the
given
KeyEvent . |
getAlt, getControl, getMeta, getShift, getShortcut, keyCombination, toString, valueOf
public KeyCharacterCombination(java.lang.String character, KeyCombination.ModifierValue shift, KeyCombination.ModifierValue control, KeyCombination.ModifierValue alt, KeyCombination.ModifierValue meta, KeyCombination.ModifierValue shortcut)
KeyCharacterCombination
for the specified main key
character and with an explicit specification of all modifier keys. Each
modifier key can be set to PRESSED
, RELEASED
or
IGNORED
.character
- the main key charactershift
- the value of the shift
modifier keycontrol
- the value of the control
modifier keyalt
- the value of the alt
modifier keymeta
- the value of the meta
modifier keyshortcut
- the value of the shortcut
modifier keypublic KeyCharacterCombination(java.lang.String character, KeyCombination.Modifier... modifiers)
KeyCharacterCombination
for the specified main key
character and the specified list of modifiers. All modifier keys which
are not explicitly listed are set to the default RELEASED
value.
All possible modifiers which change the default modifier value are
defined as constants in the KeyCombination
class.
character
- the main key charactermodifiers
- the list of modifier keys and their corresponding valuespublic final java.lang.String getCharacter()
public boolean match(KeyEvent event)
KeyEvent
. The key character of this object is first
translated to the key code which is capable of producing the character
in the current keyboard layout and then the resulting key code together
with the modifier keys are matched against the key code and key modifiers
from the KeyEvent
. This means that the method can return
true
only for KEY_PRESSED
and KEY_RELEASED
events, but not for KEY_TYPED
events, which don't have valid key
codes.match
in class KeyCombination
event
- the key eventtrue
if the key combinations match, false
otherwisepublic java.lang.String getName()
KeyCharacterCombination
.
The string representation consists of sections separated by plus characters. Each section specifies either a modifier key or the main key.
A modifier key section contains the KeyCode
name of a modifier
key. It can be prefixed with the Ignored
keyword. A non-prefixed
modifier key implies its PRESSED
value while the prefixed version
implies the IGNORED
value. If some modifier key is not specified
in the string at all, it means it has the default RELEASED
value.
The main key section contains the main key character enclosed in single quotes and is the last section in the returned string.
getName
in class KeyCombination
KeyCharacterCombination
public boolean equals(java.lang.Object obj)
KeyCharacterCombination
equals to the
specified object.equals
in class KeyCombination
obj
- the object to compare totrue
if the objects are equal, false
otherwisepublic int hashCode()
KeyCharacterCombination
.hashCode
in class KeyCombination
Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.