APIdia Launch Partner
Top Description Methods
javax.swing.text

public Interface Keymap

Known Direct Implementers
javax.swing.text.JTextComponent.DefaultKeymap
Imports
javax.swing.Action, .KeyStroke

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

Method Summary

Modifier and TypeMethod and Description
public void
addActionForKeyStroke(KeyStroke
the key sequence
key
,
Action
the action
a
)

Adds a binding to the keymap.

public Action

Returns:

the action associated with the key sequence if one is defined, otherwise null
getAction
(KeyStroke
the key sequence
key
)

Fetches the action appropriate for the given symbolic event sequence.

public Action[]

Returns:

the list of actions
getBoundActions
()

Fetches all of the actions defined in this keymap.

public KeyStroke[]

Returns:

the list of keystrokes
getBoundKeyStrokes
()

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

public Action

Returns:

the default 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.

public KeyStroke[]

Returns:

the list of keystrokes
getKeyStrokesForAction
(Action
the action
a
)

Fetches the keystrokes that will result in the given action.

public String

Returns:

the name
getName
()

Fetches the name of the set of key-bindings.

public Keymap

Returns:

the keymap
getResolveParent
()

Fetches the parent keymap used to resolve key-bindings.

public boolean

Returns:

true if the key sequence is locally defined else false
isLocallyDefined
(KeyStroke
the key sequence
key
)

Determines if the given key sequence is locally defined.

public void
removeBindings()

Removes all bindings from the keymap.

public void
removeKeyStrokeBinding(KeyStroke
the key sequence
keys
)

Removes a binding from the keymap.

public void
setDefaultAction(Action
the action
a
)

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

public void
setResolveParent(Keymap
the parent keymap
parent
)

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

Method Detail

addActionForKeyStrokeback to summary
public void addActionForKeyStroke(KeyStroke key, Action a)

Adds a binding to the keymap.

Parameters
key:KeyStroke

the key sequence

a:Action

the action

getActionback to summary
public 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:KeyStroke

the key sequence

Returns:Action

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

getBoundActionsback to summary
public Action[] getBoundActions()

Fetches all of the actions defined in this keymap.

Returns:Action[]

the list of actions

getBoundKeyStrokesback to summary
public KeyStroke[] getBoundKeyStrokes()

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

Returns:KeyStroke[]

the list of keystrokes

getDefaultActionback to summary
public 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:Action

the default action

getKeyStrokesForActionback to summary
public KeyStroke[] getKeyStrokesForAction(Action a)

Fetches the keystrokes that will result in the given action.

Parameters
a:Action

the action

Returns:KeyStroke[]

the list of keystrokes

getNameback to summary
public String getName()

Fetches the name of the set of key-bindings.

Returns:String

the name

getResolveParentback to summary
public Keymap getResolveParent()

Fetches the parent keymap used to resolve key-bindings.

Returns:Keymap

the keymap

isLocallyDefinedback to summary
public boolean isLocallyDefined(KeyStroke key)

Determines if the given key sequence is locally defined.

Parameters
key:KeyStroke

the key sequence

Returns:boolean

true if the key sequence is locally defined else false

removeBindingsback to summary
public void removeBindings()

Removes all bindings from the keymap.

removeKeyStrokeBindingback to summary
public void removeKeyStrokeBinding(KeyStroke keys)

Removes a binding from the keymap.

Parameters
keys:KeyStroke

the key sequence

setDefaultActionback to summary
public void setDefaultAction(Action a)

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

Parameters
a:Action

the action

setResolveParentback to summary
public 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.

Parameters
parent:Keymap

the parent keymap