javax.swing
public class InputMap extends Object implements Serializable
KeyStroke
s to arbitrary objects, usually Strings. This
is used in combination with ActionMap
s.
If a component receives an input event, this is looked up in
the component's InputMap
. The result is an object which
serves as a key to the component's ActionMap
. Finally
the Action
that is stored is executed.Constructor and Description |
---|
InputMap()
Creates a new
InputMap instance. |
Modifier and Type | Method and Description |
---|---|
KeyStroke[] |
allKeys()
Returns all keys of entries in this
InputMap and all its
parents. |
void |
clear()
Clears the entries from this
InputMap . |
Object |
get(KeyStroke keystroke)
Returns the binding for the specified keystroke, if there is one.
|
InputMap |
getParent()
Returns the parent of this
InputMap . |
KeyStroke[] |
keys()
Returns all keys of entries in this
InputMap . |
void |
put(KeyStroke keystroke,
Object actionMapKey)
Puts a new entry into the
InputMap . |
void |
remove(KeyStroke keystroke)
Removes an entry from this
InputMap . |
void |
setParent(InputMap parentMap)
Sets a parent for this
InputMap . |
int |
size()
Returns the number of entries in this
InputMap . |
public InputMap()
InputMap
instance. This default instance
contains no mappings and has no parent.public Object get(KeyStroke keystroke)
keystroke
- the key of the entry (null
is ignored).null
).public void put(KeyStroke keystroke, Object actionMapKey)
InputMap
. If
actionMapKey
is null
any existing entry will be
removed.keystroke
- the keystroke for the entry (null
is
ignored).actionMapKey
- the action (null
permitted).public void remove(KeyStroke keystroke)
InputMap
. Note that this will
not remove any entry from the parent map, if there is one.keystroke
- the key of the entry to remove (null
is
ignored).public InputMap getParent()
InputMap
. The default value
is null
.null
).setParent(InputMap)
public void setParent(InputMap parentMap)
InputMap
. If a parent is specified,
the get(KeyStroke)
method will look in the parent if it cannot
find an entry in this map.parentMap
- the new parent (null
permitted).getParent()
public int size()
InputMap
. This count
does not include any entries from the parent map, if there is one.public void clear()
InputMap
. The parent map, if
there is one, is not cleared.public KeyStroke[] keys()
InputMap
. This does not
include keys defined in the parent, if there is one (use the
allKeys()
method for that case).
null
when no entries have been added to the map,
and a zero length array if entries have been added but subsequently
removed (or cleared) from the map.null
or have zero length).