java.lang.Object
is.codion.swing.common.ui.key.KeyEvents
A factory for key event builders.
JTextField textField = new JTextField();
KeyEvents.builder()
.keyCode(VK_DOWN)
.onKeyRelease(false)
.modifiers(MENU_SHORTCUT_MASK)
.condition(WHEN_FOCUSED)
.action(new FindNextAction())
.enable(textField);
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
A Builder for adding a key event to a component, with a default onKeyRelease trigger and conditionJComponent.WHEN_FOCUSED
. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The platform-appropriate modifier mask for menu shortcuts. -
Method Summary
Modifier and TypeMethodDescriptionstatic KeyEvents.Builder
builder()
Instantiates a newKeyEvents.Builder
instance.static KeyStroke
keyStroke
(int keyCode) Returns aKeyStroke
with the given keyCode and no modifiers.static KeyStroke
keyStroke
(int keyCode, int modifiers) Returns aKeyStroke
with the given keyCode and modifiers.static KeyStroke
Returns aKeyStroke
parsed from the given string.
-
Field Details
-
MENU_SHORTCUT_MASK
public static final int MENU_SHORTCUT_MASKThe platform-appropriate modifier mask for menu shortcuts.- Windows/Linux:
InputEvent.CTRL_DOWN_MASK
(Control key) - macOS:
InputEvent.META_DOWN_MASK
(Command key)
InputEvent.CTRL_DOWN_MASK
to provide native keyboard shortcuts on each platform. For example, shortcuts using this mask will appear as Ctrl+F on Windows/Linux and ⌘+F on macOS.- See Also:
- Windows/Linux:
-
-
Method Details
-
builder
Instantiates a newKeyEvents.Builder
instance. Note that an Action must be set viaKeyEvents.Builder.action(Action)
before enabling/disabling.- Returns:
- a
KeyEvents.Builder
instance.
-
keyStroke
Returns aKeyStroke
with the given keyCode and no modifiers.- Parameters:
keyCode
- the key code- Returns:
- a keystroke
- See Also:
-
keyStroke
Returns aKeyStroke
with the given keyCode and modifiers.- Parameters:
keyCode
- the key codemodifiers
- the modifiers- Returns:
- a keystroke
- See Also:
-
keyStroke
Returns aKeyStroke
parsed from the given string.- Parameters:
keyStroke
- the keystroke to parse- Returns:
- a keystroke
- See Also:
-