This documentation differs from the official API.
Jadeite adds
extra features to the API including:
variable font sizes,
constructions examples,
placeholders for classes and methods, and auto-generated “See Also” links.
Additionally it
is missing some items found in standard Javadoc documentation, including:
generics type information,
“Deprecated” tags and comments,
“See Also” links,
along with other minor differences.
Please send any questions or feedback to
bam@cs.cmu.edu.
javax.swing.text
interface Keymap
-
Most common ways to construct:
-
JTextComponent c = …;
Keymap k = c.getKeymap();
Based on 23 examples
-
-
JTextField f = …;
Keymap map = f.getKeymap();
Based on 19 examples
public interface Keymap
A collection of bindings of KeyStrokes to actions. The
bindings are basically name-value pairs that potentially
resolve in a hierarchy.
Method Summary |
void |
Adds a binding to the keymap.
|
Action |
Fetches the action appropriate for the given symbolic
event sequence.
|
Action[] |
Fetches all of the actions defined in this keymap.
|
KeyStroke[] |
Fetches all of the keystrokes in this map that
are bound to some action.
|
Action |
Fetches the default action to fire if a
key is typed (i.e.
|
KeyStroke[] |
Fetches the keystrokes that will result in
the given action.
|
String |
Fetches the name of the set of key-bindings.
|
Keymap |
Fetches the parent keymap used to resolve key-bindings.
|
boolean |
Determines if the given key sequence is locally defined.
|
void |
Removes all bindings from the keymap.
|
void |
Removes a binding from the keymap.
|
void |
Set the default action to fire if a key is typed.
|
void |
Sets the parent keymap, which will be used to
resolve key-bindings.
|
addActionForKeyStroke
public void addActionForKeyStroke(KeyStroke key,
Action a)
-
Adds a binding to the keymap.
- Parameters:
key
- the key sequence
a
- the action
getAction
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
- the key sequence
- Returns:
- the action associated with the key
sequence if one is defined, otherwise
null
getBoundActions
public Action[] getBoundActions()
-
Fetches all of the actions defined in this keymap.
- Returns:
- the list of actions
getBoundKeyStrokes
public KeyStroke[] getBoundKeyStrokes()
-
Fetches all of the keystrokes in this map that
are bound to some action.
- Returns:
- the list of keystrokes
getDefaultAction
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:
- the default action
getKeyStrokesForAction
public KeyStroke[] getKeyStrokesForAction(Action a)
-
Fetches the keystrokes that will result in
the given action.
- Parameters:
a
- the action
- Returns:
- the list of keystrokes
getName
public String getName()
-
Fetches the name of the set of key-bindings.
- Returns:
- the name
getResolveParent
public Keymap getResolveParent()
-
Fetches the parent keymap used to resolve key-bindings.
- Returns:
- the keymap
isLocallyDefined
public 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
removeBindings
public void removeBindings()
-
Removes all bindings from the keymap.
removeKeyStrokeBinding
public void removeKeyStrokeBinding(KeyStroke keys)
-
Removes a binding from the keymap.
- Parameters:
keys
- the key sequence
setDefaultAction
public void setDefaultAction(Action a)
-
Set the default action to fire if a key is typed.
- Parameters:
a
- the action
setResolveParent
public void setResolveParent(Keymap parent)
-
Sets the parent keymap, which will be used to
resolve key-bindings.
- Parameters:
parent
- the parent keymap
This documentation differs from the official API.
Jadeite adds
extra features to the API including:
variable font sizes,
constructions examples,
placeholders for classes and methods, and auto-generated “See Also” links.
Additionally it
is missing some items found in standard Javadoc documentation, including:
generics type information,
“Deprecated” tags and comments,
“See Also” links,
along with other minor differences.
Please send any questions or feedback to
bam@cs.cmu.edu.
This page displays the
Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
The official Sun™ documentation can be found here at
http://java.sun.com/javase/6/docs/api/.