com.levigo.jadice.appbase.tool
Class KeyBindingsTool
java.lang.Object
com.levigo.jadice.swing.tool.Tool
com.levigo.jadice.appbase.tool.KeyBindingsTool
- All Implemented Interfaces:
- MenuContributor
public class KeyBindingsTool
- extends Tool
A Tool
which allows to map key strokes occurring on a ViewComponent
to specific
Action
s. Its intention is to provide an easy way to set up key bindings integrating with
the Tool API's flexibility.
Note that, naturally, this Tool
can only react on key events occurring on the
ViewComponent
it is registered for.
Methods inherited from class com.levigo.jadice.swing.tool.Tool |
contribute, getActivationFeedback, getActivationRequest, getActivationRequestForKeyPressed, getActivationRequestForMouseDragged, getActivationRequestForMousePressed, getCursor, getDispatchPriority, getManager, getRenderPriority, handleEditEvent, handleKeyReleased, handleKeyTyped, handleMouseClicked, handleMouseDragged, handleMouseEntered, handleMouseExited, handleMouseMoved, handleMousePressed, handleMouseReleased, handleMouseWheelMoved, propagatePropertyChange, render, setActive, setCursor, setEnabled, setManager, setStatusFeedback |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
KeyBindingsTool
public KeyBindingsTool()
handleKeyPressed
protected void handleKeyPressed(KeyEditEvent e,
boolean isActive)
- Description copied from class:
Tool
- Invoked when a key has been pressed. See the class description for
KeyEvent
for a
definition of a key pressed event.
- Overrides:
handleKeyPressed
in class Tool
isActive
- whether this tool is currently active
putKeyBinding
@CallOnEDT
public void putKeyBinding(KeyStroke ks,
Action action)
- Instruct this tool to react upon the given
KeyStroke
by executing the given
Action
.
- Parameters:
ks
- the KeyStroke
to be used as execution triggeraction
- the Action
to be executed
removeKeyBinding
@CallOnEDT
public Action removeKeyBinding(KeyStroke ks)
- Remove the given
KeyStroke
's mapping to an Action
. After calling this method,
this Tool
will no longer react upon the given KeyStroke
(until some other key
binding is created using putKeyBinding(KeyStroke, Action)
).
- Parameters:
ks
- KeyStroke
to remove the mapping for
- Returns:
- the
Action
that used to be triggered by the KeyStroke
, but now has been
removed. Returns null
if no Action
was bound to the given
KeyStroke
.
getKeyBindingAction
@CallOnEDT
public Action getKeyBindingAction(KeyStroke ks)
- Retrieve the
Action
currently mapped to the given KeyStroke
.
- Parameters:
ks
- KeyStroke
to get the associated action for
- Returns:
- the
Action
that is executed whenever the given KeyStroke
occurs
Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.