public interface

Keymap

javax.swing.text.Keymap

Class Overview

A collection of bindings of KeyStrokes to actions. The bindings are basically name-value pairs that potentially resolve in a hierarchy.

Summary

Public Methods
abstract void addActionForKeyStroke(KeyStroke key, Action a)
Adds a binding to the keymap.
abstract Action getAction(KeyStroke key)
Fetches the action appropriate for the given symbolic event sequence.
abstract Action[] getBoundActions()
Fetches all of the actions defined in this keymap.
abstract KeyStroke[] getBoundKeyStrokes()
Fetches all of the keystrokes in this map that are bound to some action.
abstract Action getDefaultAction()
Fetches the default action to fire if a key is typed (i.e.
abstract KeyStroke[] getKeyStrokesForAction(Action a)
Fetches the keystrokes that will result in the given action.
abstract String getName()
Fetches the name of the set of key-bindings.
abstract Keymap getResolveParent()
Fetches the parent keymap used to resolve key-bindings.
abstract boolean isLocallyDefined(KeyStroke key)
Determines if the given key sequence is locally defined.
abstract void removeBindings()
Removes all bindings from the keymap.
abstract void removeKeyStrokeBinding(KeyStroke keys)
Removes a binding from the keymap.
abstract void setDefaultAction(Action a)
Set the default action to fire if a key is typed.
abstract void setResolveParent(Keymap parent)
Sets the parent keymap, which will be used to resolve key-bindings.

Public Methods

public abstract void addActionForKeyStroke (KeyStroke key, Action a)

Adds a binding to the keymap.

Parameters
key the key sequence
a the action

public abstract Action 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.

Parameters
key the key sequence
Returns
  • the action associated with the key sequence if one is defined, otherwise null

public abstract Action[] getBoundActions ()

Fetches all of the actions defined in this keymap.

Returns
  • the list of actions

public abstract KeyStroke[] getBoundKeyStrokes ()

Fetches all of the keystrokes in this map that are bound to some action.

Returns
  • the list of keystrokes

public abstract 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.

Returns
  • the default action

public abstract KeyStroke[] getKeyStrokesForAction (Action a)

Fetches the keystrokes that will result in the given action.

Parameters
a the action
Returns
  • the list of keystrokes

public abstract String getName ()

Fetches the name of the set of key-bindings.

Returns
  • the name

public abstract Keymap getResolveParent ()

Fetches the parent keymap used to resolve key-bindings.

Returns
  • the keymap

public abstract boolean isLocallyDefined (KeyStroke key)

Determines if the given key sequence is locally defined.

Parameters
key the key sequence
Returns
  • true if the key sequence is locally defined else false

public abstract void removeBindings ()

Removes all bindings from the keymap.

public abstract void removeKeyStrokeBinding (KeyStroke keys)

Removes a binding from the keymap.

Parameters
keys the key sequence

public abstract void setDefaultAction (Action a)

Set the default action to fire if a key is typed.

Parameters
a the action

public abstract void setResolveParent (Keymap parent)

Sets the parent keymap, which will be used to resolve key-bindings.

Parameters
parent the parent keymap