Class InputMap
java.lang.Object
javax.swing.InputMap
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ComponentInputMap, InputMapUIResource
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.
- Since:
- 1.3
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallKeys()Returns an array of theKeyStrokes defined in thisInputMapand its parent.voidclear()Removes all the mappings from thisInputMap.Returns the binding forkeyStroke, messaging the parentInputMapif the binding is not locally defined.Gets thisInputMap's parent.keys()Returns theKeyStrokes that are bound in thisInputMap.voidAdds a binding forkeyStroketoactionMapKey.voidRemoves the binding forkeyfrom thisInputMap.voidSets thisInputMap's parent.intsize()Returns the number ofKeyStrokebindings.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Constructor Details
-
InputMap
public InputMap()Creates anInputMapwith no parent and no mappings.
-
-
Method Details
-
setParent
Sets thisInputMap's parent.- Parameters:
map- theInputMapthat is the parent of this one
-
getParent
Gets thisInputMap's parent.- Returns:
- map the
InputMapthat is the parent of this one, or null if thisInputMaphas no parent
-
put
-
get
-
remove
Removes the binding forkeyfrom thisInputMap.- Parameters:
key- theKeyStrokefor which to remove the binding
-
clear
public void clear()Removes all the mappings from thisInputMap. -
keys
Returns theKeyStrokes that are bound in thisInputMap.- Returns:
- an array of the
KeyStrokes that are bound in thisInputMap
-
size
public int size()Returns the number ofKeyStrokebindings.- Returns:
- the number of
KeyStrokebindings
-
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
-