public interface Keymap
A collection of bindings of KeyStrokes to actions. The bindings are basically name-value pairs that potentially resolve in a hierarchy.
String getName()
Fetches the name of the set of key-bindings.
Action getDefaultAction()
Fetches the default action to fire if a key is typed (i.e. a KEY_TYPED KeyEvent is received) and there is no binding for it. Typically this would be some action that inserts text so that the keymap doesn't require an action for each possible key.
void setDefaultAction(Action a)
Set the default action to fire if a key is typed.
a
- the actionAction getAction(KeyStroke key)
Fetches the action appropriate for the given symbolic event sequence. This is used by JTextController to determine how to interpret key sequences. If the binding is not resolved locally, an attempt is made to resolve through the parent keymap, if one is set.
key
- the key sequencenull
KeyStroke[] getBoundKeyStrokes()
Fetches all of the keystrokes in this map that are bound to some action.
Action[] getBoundActions()
Fetches all of the actions defined in this keymap.
KeyStroke[] getKeyStrokesForAction(Action a)
Fetches the keystrokes that will result in the given action.
a
- the actionboolean isLocallyDefined(KeyStroke key)
Determines if the given key sequence is locally defined.
key
- the key sequencevoid addActionForKeyStroke(KeyStroke key, Action a)
Adds a binding to the keymap.
key
- the key sequencea
- the actionvoid removeKeyStrokeBinding(KeyStroke keys)
Removes a binding from the keymap.
keys
- the key sequencevoid removeBindings()
Removes all bindings from the keymap.
Keymap getResolveParent()
Fetches the parent keymap used to resolve key-bindings.
void setResolveParent(Keymap parent)
Sets the parent keymap, which will be used to resolve key-bindings. The behavior is unspecified if a Keymap
has itself as one of its resolve parents.
parent
- the parent keymap
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.