Top Description Fields Constructors Methods
javax.swing

public Class InputMap

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Known Direct Subclasses
javax.swing.plaf.InputMapUIResource, javax.swing.text.JTextComponent.KeymapWrapper, javax.swing.ComponentInputMap
Annotations
@SuppressWarnings:serial
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .Serial, .Serializable, java.util.HashMap

InputMap provides a binding between an input event (currently only KeyStrokes are used) and an Object. InputMaps are usually used with an ActionMap, to determine an Action to perform when a key is pressed. An InputMap can have a parent that is searched for bindings not defined in the InputMap.

As with ActionMap if you create a cycle, eg:

  InputMap am = new InputMap();
  InputMap bm = new InputMap():
  am.setParent(bm);
  bm.setParent(am);
some of the methods will cause a StackOverflowError to be thrown.
Author
Scott Violet
Since
1.3

Field Summary

Modifier and TypeField and Description
private transient ArrayTable
arrayTable

Handles the mapping between KeyStroke and Action name.

private InputMap
parent

Parent that handles any bindings we don't contain.

Constructor Summary

AccessConstructor and Description
public
InputMap()

Creates an InputMap with no parent and no mappings.

Method Summary

Modifier and TypeMethod and Description
public KeyStroke[]

Returns:

an array of the KeyStrokes defined in this InputMap and its parent
allKeys
()

Returns an array of the KeyStrokes defined in this InputMap and its parent.

public void
clear()

Removes all the mappings from this InputMap.

public Object

Returns:

the binding for keyStroke
get
(KeyStroke
the KeyStroke for which to get the binding
keyStroke
)

Returns the binding for keyStroke, messaging the parent InputMap if the binding is not locally defined.

public InputMap

Returns:

map the InputMap that is the parent of this one, or null if this InputMap has no parent
getParent
()

Gets this InputMap's parent.

public KeyStroke[]

Returns:

an array of the KeyStrokes that are bound in this InputMap
keys
()

Returns the KeyStrokes that are bound in this InputMap.

public void
put(KeyStroke
a KeyStroke
keyStroke
,
Object
an action map key
actionMapKey
)

Adds a binding for keyStroke to actionMapKey.

private void
public void
remove(KeyStroke
the KeyStroke for which to remove the binding
key
)

Removes the binding for key from this InputMap.

public void
setParent(InputMap
the InputMap that is the parent of this one
map
)

Sets this InputMap's parent.

public int

Returns:

the number of KeyStroke bindings
size
()

Returns the number of KeyStroke bindings.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

arrayTableback to summary
private transient ArrayTable arrayTable

Handles the mapping between KeyStroke and Action name.

parentback to summary
private InputMap parent

Parent that handles any bindings we don't contain.

Constructor Detail

InputMapback to summary
public InputMap()

Creates an InputMap with no parent and no mappings.

Method Detail

allKeysback to summary
public KeyStroke[] allKeys()

Returns an array of the KeyStrokes defined in this InputMap and its parent. This differs from keys() in that this method includes the keys defined in the parent.

Returns:KeyStroke[]

an array of the KeyStrokes defined in this InputMap and its parent

clearback to summary
public void clear()

Removes all the mappings from this InputMap.

getback to summary
public Object get(KeyStroke keyStroke)

Returns the binding for keyStroke, messaging the parent InputMap if the binding is not locally defined.

Parameters
keyStroke:KeyStroke

the KeyStroke for which to get the binding

Returns:Object

the binding for keyStroke

getParentback to summary
public InputMap getParent()

Gets this InputMap's parent.

Returns:InputMap

map the InputMap that is the parent of this one, or null if this InputMap has no parent

keysback to summary
public KeyStroke[] keys()

Returns the KeyStrokes that are bound in this InputMap.

Returns:KeyStroke[]

an array of the KeyStrokes that are bound in this InputMap

putback to summary
public void put(KeyStroke keyStroke, Object actionMapKey)

Adds a binding for keyStroke to actionMapKey. If actionMapKey is null, this removes the current binding for keyStroke.

Parameters
keyStroke:KeyStroke

a KeyStroke

actionMapKey:Object

an action map key

readObjectback to summary
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException
Annotations
@Serial
removeback to summary
public void remove(KeyStroke key)

Removes the binding for key from this InputMap.

Parameters
key:KeyStroke

the KeyStroke for which to remove the binding

setParentback to summary
public void setParent(InputMap map)

Sets this InputMap's parent.

Parameters
map:InputMap

the InputMap that is the parent of this one

sizeback to summary
public int size()

Returns the number of KeyStroke bindings.

Returns:int

the number of KeyStroke bindings

writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException
Annotations
@Serial