- java.lang.Object
- 
- javax.swing.InputMap
 
- 
- All Implemented Interfaces:
- Serializable
 - Direct Known Subclasses:
- ComponentInputMap,- InputMapUIResource
 
 public class InputMap extends Object implements Serializable InputMapprovides a binding between an input event (currently onlyKeyStrokes are used) and anObject.InputMaps are usually used with anActionMap, to determine anActionto perform when a key is pressed. AnInputMapcan have a parent that is searched for bindings not defined in theInputMap.As with ActionMapif 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.- Since:
- 1.3
- See Also:
- Serialized Form
 
- 
- 
Constructor SummaryConstructors Constructor Description InputMap()Creates anInputMapwith no parent and no mappings.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyStroke[]allKeys()Returns an array of theKeyStrokes defined in thisInputMapand its parent.voidclear()Removes all the mappings from thisInputMap.Objectget(KeyStroke keyStroke)Returns the binding forkeyStroke, messaging the parentInputMapif the binding is not locally defined.InputMapgetParent()Gets thisInputMap's parent.KeyStroke[]keys()Returns theKeyStrokes that are bound in thisInputMap.voidput(KeyStroke keyStroke, Object actionMapKey)Adds a binding forkeyStroketoactionMapKey.voidremove(KeyStroke key)Removes the binding forkeyfrom thisInputMap.voidsetParent(InputMap map)Sets thisInputMap's parent.intsize()Returns the number ofKeyStrokebindings.
 
- 
- 
- 
Method Detail- 
setParentpublic void setParent(InputMap map) Sets thisInputMap's parent.- Parameters:
- map- the- InputMapthat is the parent of this one
 
 - 
getParentpublic InputMap getParent() Gets thisInputMap's parent.- Returns:
- map the InputMapthat is the parent of this one, or null if thisInputMaphas no parent
 
 - 
putpublic void put(KeyStroke keyStroke, Object actionMapKey) Adds a binding forkeyStroketoactionMapKey. IfactionMapKeyis null, this removes the current binding forkeyStroke.- Parameters:
- keyStroke- a- KeyStroke
- actionMapKey- an action map key
 
 - 
getpublic Object get(KeyStroke keyStroke) Returns the binding forkeyStroke, messaging the parentInputMapif the binding is not locally defined.- Parameters:
- keyStroke- the- KeyStrokefor which to get the binding
- Returns:
- the binding for keyStroke
 
 - 
removepublic void remove(KeyStroke key) Removes the binding forkeyfrom thisInputMap.- Parameters:
- key- the- KeyStrokefor which to remove the binding
 
 - 
clearpublic void clear() Removes all the mappings from thisInputMap.
 - 
keyspublic KeyStroke[] keys() Returns theKeyStrokes that are bound in thisInputMap.- Returns:
- an array of the KeyStrokes that are bound in thisInputMap
 
 - 
sizepublic int size() Returns the number ofKeyStrokebindings.- Returns:
- the number of KeyStrokebindings
 
 - 
allKeyspublic KeyStroke[] allKeys() Returns an array of theKeyStrokes defined in thisInputMapand its parent. This differs fromkeys()in that this method includes the keys defined in the parent.- Returns:
- an array of the KeyStrokes defined in thisInputMapand its parent
 
 
- 
 
-