javax.swing.text
Class JTextComponent.DefaultKeymap

java.lang.Object
  extended byjavax.swing.text.JTextComponent.DefaultKeymap
All Implemented Interfaces:
Keymap
Enclosing class:
JTextComponent

static class JTextComponent.DefaultKeymap
extends Object
implements Keymap


Field Summary
(package private)  Hashtable bindings
           
(package private)  Action defaultAction
           
(package private)  String nm
           
(package private)  Keymap parent
           
 
Constructor Summary
(package private) JTextComponent.DefaultKeymap(String nm, Keymap parent)
           
 
Method Summary
 void addActionForKeyStroke(KeyStroke key, Action a)
          Adds a binding to the keymap.
 Action getAction(KeyStroke key)
          Fetches the action appropriate for the given symbolic event sequence.
 Action[] getBoundActions()
          Fetches all of the actions defined in this keymap.
 KeyStroke[] getBoundKeyStrokes()
          Fetches all of the keystrokes in this map that are bound to some action.
 Action getDefaultAction()
          Fetch the default action to fire if a key is typed (ie a KEY_TYPED KeyEvent is received) and there is no binding for it.
 KeyStroke[] getKeyStrokesForAction(Action a)
          Fetches the keystrokes that will result in the given action.
 String getName()
          Fetches the name of the set of key-bindings.
 Keymap getResolveParent()
          Fetches the parent keymap used to resolve key-bindings.
 boolean isLocallyDefined(KeyStroke key)
          Determines if the given key sequence is locally defined.
 void removeBindings()
          Removes all bindings from the keymap.
 void removeKeyStrokeBinding(KeyStroke key)
          Removes a binding from the keymap.
 void setDefaultAction(Action a)
          Set the default action to fire if a key is typed.
 void setResolveParent(Keymap parent)
          Sets the parent keymap, which will be used to resolve key-bindings.
 String toString()
          String representation of the keymap... potentially a very long string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nm

String nm

parent

Keymap parent

bindings

Hashtable bindings

defaultAction

Action defaultAction
Constructor Detail

JTextComponent.DefaultKeymap

JTextComponent.DefaultKeymap(String nm,
                             Keymap parent)
Method Detail

getDefaultAction

public Action getDefaultAction()
Fetch the default action to fire if a key is typed (ie 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.

Specified by:
getDefaultAction in interface Keymap
Returns:
the default action

setDefaultAction

public void setDefaultAction(Action a)
Set the default action to fire if a key is typed.

Specified by:
setDefaultAction in interface Keymap
Parameters:
a - the action

getName

public String getName()
Description copied from interface: Keymap
Fetches the name of the set of key-bindings.

Specified by:
getName in interface Keymap
Returns:
the name

getAction

public Action getAction(KeyStroke key)
Description copied from interface: Keymap
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.

Specified by:
getAction in interface Keymap
Parameters:
key - the key sequence
Returns:
the action associated with the key sequence if one is defined, otherwise null

getBoundKeyStrokes

public KeyStroke[] getBoundKeyStrokes()
Description copied from interface: Keymap
Fetches all of the keystrokes in this map that are bound to some action.

Specified by:
getBoundKeyStrokes in interface Keymap
Returns:
the list of keystrokes

getBoundActions

public Action[] getBoundActions()
Description copied from interface: Keymap
Fetches all of the actions defined in this keymap.

Specified by:
getBoundActions in interface Keymap
Returns:
the list of actions

getKeyStrokesForAction

public KeyStroke[] getKeyStrokesForAction(Action a)
Description copied from interface: Keymap
Fetches the keystrokes that will result in the given action.

Specified by:
getKeyStrokesForAction in interface Keymap
Parameters:
a - the action
Returns:
the list of keystrokes

isLocallyDefined

public boolean isLocallyDefined(KeyStroke key)
Description copied from interface: Keymap
Determines if the given key sequence is locally defined.

Specified by:
isLocallyDefined in interface Keymap
Parameters:
key - the key sequence
Returns:
true if the key sequence is locally defined else false

addActionForKeyStroke

public void addActionForKeyStroke(KeyStroke key,
                                  Action a)
Description copied from interface: Keymap
Adds a binding to the keymap.

Specified by:
addActionForKeyStroke in interface Keymap
Parameters:
key - the key sequence
a - the action

removeKeyStrokeBinding

public void removeKeyStrokeBinding(KeyStroke key)
Description copied from interface: Keymap
Removes a binding from the keymap.

Specified by:
removeKeyStrokeBinding in interface Keymap
Parameters:
key - the key sequence

removeBindings

public void removeBindings()
Description copied from interface: Keymap
Removes all bindings from the keymap.

Specified by:
removeBindings in interface Keymap

getResolveParent

public Keymap getResolveParent()
Description copied from interface: Keymap
Fetches the parent keymap used to resolve key-bindings.

Specified by:
getResolveParent in interface Keymap
Returns:
the keymap

setResolveParent

public void setResolveParent(Keymap parent)
Description copied from interface: Keymap
Sets the parent keymap, which will be used to resolve key-bindings.

Specified by:
setResolveParent in interface Keymap
Parameters:
parent - the parent keymap

toString

public String toString()
String representation of the keymap... potentially a very long string.

Overrides:
toString in class Object
Returns:
a string representation of the object.