APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.scene.input

public final Class KeyCharacterCombination

extends KeyCombination
Class Inheritance
Imports
com.sun.javafx.tk.Toolkit, javafx.beans.NamedArg

This class represents a key combination in which the main key is specified by its character. This is the preferred way to specify a shortcut involving a symbol or punctuation.

The location of a symbol or punctuation mark can vary from one keyboard layout to another. For example, on an English QWERTY layout the '+' symbol is the shifted character on KeyCode#EQUALS but on a German layout it is the unmodified character on KeyCode#PLUS. The '+' symbol also appears as KeyCode#ADD on the numeric keypad. When matching against a key event a key character combination queries the OS to determine which keys the character appears on in the current layout.

Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
private String
character

The key character associated with this key combination.

Inherited from javafx.scene.input.KeyCombination:
ALT_ANYALT_DOWNCONTROL_ANYCONTROL_DOWNMETA_ANYMETA_DOWNNO_MATCHSHIFT_ANYSHIFT_DOWNSHORTCUT_ANYSHORTCUT_DOWN

Constructor Summary

AccessConstructor and Description
public
KeyCharacterCombination(final String
the main key character
character
,
final KeyCombination.ModifierValue
the value of the shift modifier key
shift
,
final KeyCombination.ModifierValue
the value of the control modifier key
control
,
final KeyCombination.ModifierValue
the value of the alt modifier key
alt
,
final KeyCombination.ModifierValue
the value of the meta modifier key
meta
,
final KeyCombination.ModifierValue
the value of the shortcut modifier key
shortcut
)

Constructs a KeyCharacterCombination for the specified main key character and with an explicit specification of all modifier keys.

public
KeyCharacterCombination(final String
the main key character
character
,
final KeyCombination.Modifier...
the list of modifier keys and their corresponding values
modifiers
)

Constructs a KeyCharacterCombination for the specified main key character and the specified list of modifiers.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the objects are equal, false otherwise
equals
(final Object
the object to compare to
obj
)

Overrides javafx.scene.input.KeyCombination.equals.

Tests whether this KeyCharacterCombination equals to the specified object.

public final String

Returns:

The key character associated with this key combination
getCharacter
()

Gets the key character associated with this key combination.

public String
getDisplayText()

Overrides javafx.scene.input.KeyCombination.getDisplayText.

Returns a string representation of this KeyCombination that is suitable for display in a user interface (for example, beside a menu item).

public String

Returns:

the string representation of this KeyCharacterCombination
getName
()

Overrides javafx.scene.input.KeyCombination.getName.

Returns a string representation of this KeyCharacterCombination.

public int

Returns:

the hash code value
hashCode
()

Overrides javafx.scene.input.KeyCombination.hashCode.

Returns a hash code value for this KeyCharacterCombination.

public boolean

Returns:

true if the key combinations match, false otherwise
match
(final KeyEvent
the key event
event
)

Overrides javafx.scene.input.KeyCombination.match.

Tests whether this key combination matches the key combination in the given KeyEvent.

private static void
validateKeyCharacter(final String keyCharacter)

Inherited from javafx.scene.input.KeyCombination:
getAltgetControlgetMetagetModifiergetShiftgetShortcutkeyCombinationtoStringvalueOf

Field Detail

characterback to summary
private String character

The key character associated with this key combination.

Constructor Detail

KeyCharacterCombinationback to summary
public KeyCharacterCombination(final String character, final KeyCombination.ModifierValue shift, final KeyCombination.ModifierValue control, final KeyCombination.ModifierValue alt, final KeyCombination.ModifierValue meta, final KeyCombination.ModifierValue shortcut)

Constructs a 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.

Parameters
character:String

the main key character

shift:KeyCombination.ModifierValue

the value of the shift modifier key

control:KeyCombination.ModifierValue

the value of the control modifier key

alt:KeyCombination.ModifierValue

the value of the alt modifier key

meta:KeyCombination.ModifierValue

the value of the meta modifier key

shortcut:KeyCombination.ModifierValue

the value of the shortcut modifier key

KeyCharacterCombinationback to summary
public KeyCharacterCombination(final String character, final KeyCombination.Modifier... modifiers)

Constructs a 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.

Parameters
character:String

the main key character

modifiers:KeyCombination.Modifier[]

the list of modifier keys and their corresponding values

Method Detail

equalsback to summary
public boolean equals(final Object obj)

Overrides javafx.scene.input.KeyCombination.equals.

Tests whether this KeyCharacterCombination equals to the specified object.

Parameters
obj:Object

the object to compare to

Returns:boolean

true if the objects are equal, false otherwise

Annotations
@Override
getCharacterback to summary
public final String getCharacter()

Gets the key character associated with this key combination.

Returns:String

The key character associated with this key combination

getDisplayTextback to summary
public String getDisplayText()

Overrides javafx.scene.input.KeyCombination.getDisplayText.

Doc from javafx.scene.input.KeyCombination.getDisplayText.

Returns a string representation of this KeyCombination that is suitable for display in a user interface (for example, beside a menu item).

Annotations
@Override
getNameback to summary
public String getName()

Overrides javafx.scene.input.KeyCombination.getName.

Returns a string representation of this 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.

Returns:String

the string representation of this KeyCharacterCombination

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides javafx.scene.input.KeyCombination.hashCode.

Returns a hash code value for this KeyCharacterCombination.

Returns:int

the hash code value

Annotations
@Override
matchback to summary
public boolean match(final KeyEvent event)

Overrides javafx.scene.input.KeyCombination.match.

Tests whether this key combination matches the key combination in the given KeyEvent. The key character of this object is first translated to the key codes which are capable of producing the character in the current keyboard layout and then the resulting key codes 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.

Parameters
event:KeyEvent

the key event

Returns:boolean

true if the key combinations match, false otherwise

Annotations
@Override
validateKeyCharacterback to summary
private static void validateKeyCharacter(final String keyCharacter)