javax.swing
Class InputMap

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.swing.InputMap
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable
Direct Known Subclasses:
ComponentInputMap sample code for javax.swing.ComponentInputMap definition code for javax.swing.ComponentInputMap , InputMapUIResource sample code for javax.swing.plaf.InputMapUIResource definition code for javax.swing.plaf.InputMapUIResource

public class InputMap
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Serializable sample code for java.io.Serializable definition code for java.io.Serializable

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
See Also:
Serialized Form

Constructor Summary
InputMap sample code for javax.swing.InputMap.InputMap() definition code for javax.swing.InputMap.InputMap() ()
          Creates an InputMap with no parent and no mappings.
 
Method Summary
 KeyStroke sample code for javax.swing.KeyStroke definition code for javax.swing.KeyStroke [] allKeys sample code for javax.swing.InputMap.allKeys() definition code for javax.swing.InputMap.allKeys() ()
          Returns an array of the KeyStrokes defined in this InputMap and its parent.
 void clear sample code for javax.swing.InputMap.clear() definition code for javax.swing.InputMap.clear() ()
          Removes all the mappings from this InputMap.
 Object sample code for java.lang.Object definition code for java.lang.Object get sample code for javax.swing.InputMap.get(javax.swing.KeyStroke) definition code for javax.swing.InputMap.get(javax.swing.KeyStroke) (KeyStroke sample code for javax.swing.KeyStroke definition code for javax.swing.KeyStroke  keyStroke)
          Returns the binding for keyStroke, messaging the parent InputMap if the binding is not locally defined.
 InputMap sample code for javax.swing.InputMap definition code for javax.swing.InputMap getParent sample code for javax.swing.InputMap.getParent() definition code for javax.swing.InputMap.getParent() ()
          Gets this InputMap's parent.
 KeyStroke sample code for javax.swing.KeyStroke definition code for javax.swing.KeyStroke [] keys sample code for javax.swing.InputMap.keys() definition code for javax.swing.InputMap.keys() ()
          Returns the KeyStrokes that are bound in this InputMap.
 void put sample code for javax.swing.InputMap.put(javax.swing.KeyStroke, java.lang.Object) definition code for javax.swing.InputMap.put(javax.swing.KeyStroke, java.lang.Object) (KeyStroke sample code for javax.swing.KeyStroke definition code for javax.swing.KeyStroke  keyStroke, Object sample code for java.lang.Object definition code for java.lang.Object  actionMapKey)
          Adds a binding for keyStroke to actionMapKey.
 void remove sample code for javax.swing.InputMap.remove(javax.swing.KeyStroke) definition code for javax.swing.InputMap.remove(javax.swing.KeyStroke) (KeyStroke sample code for javax.swing.KeyStroke definition code for javax.swing.KeyStroke  key)
          Removes the binding for key from this InputMap.
 void setParent sample code for javax.swing.InputMap.setParent(javax.swing.InputMap) definition code for javax.swing.InputMap.setParent(javax.swing.InputMap) (InputMap sample code for javax.swing.InputMap definition code for javax.swing.InputMap  map)
          Sets this InputMap's parent.
 int size sample code for javax.swing.InputMap.size() definition code for javax.swing.InputMap.size() ()
          Returns the number of KeyStroke bindings.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

InputMap sample code for javax.swing.InputMap() definition code for javax.swing.InputMap()

public InputMap()
Creates an InputMap with no parent and no mappings.

Method Detail

setParent sample code for javax.swing.InputMap.setParent(javax.swing.InputMap) definition code for javax.swing.InputMap.setParent(javax.swing.InputMap)

public void setParent(InputMap sample code for javax.swing.InputMap definition code for javax.swing.InputMap  map)
Sets this InputMap's parent.

Parameters:
map - the InputMap that is the parent of this one

getParent sample code for javax.swing.InputMap.getParent() definition code for javax.swing.InputMap.getParent()

public InputMap sample code for javax.swing.InputMap definition code for javax.swing.InputMap  getParent()
Gets this InputMap's parent.

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

put sample code for javax.swing.InputMap.put(javax.swing.KeyStroke, java.lang.Object) definition code for javax.swing.InputMap.put(javax.swing.KeyStroke, java.lang.Object)

public void put(KeyStroke sample code for javax.swing.KeyStroke definition code for javax.swing.KeyStroke  keyStroke,
                Object sample code for java.lang.Object definition code for java.lang.Object  actionMapKey)
Adds a binding for keyStroke to actionMapKey. If actionMapKey is null, this removes the current binding for keyStroke.


get sample code for javax.swing.InputMap.get(javax.swing.KeyStroke) definition code for javax.swing.InputMap.get(javax.swing.KeyStroke)

public Object sample code for java.lang.Object definition code for java.lang.Object  get(KeyStroke sample code for javax.swing.KeyStroke definition code for javax.swing.KeyStroke  keyStroke)
Returns the binding for keyStroke, messaging the parent InputMap if the binding is not locally defined.


remove sample code for javax.swing.InputMap.remove(javax.swing.KeyStroke) definition code for javax.swing.InputMap.remove(javax.swing.KeyStroke)

public void remove(KeyStroke sample code for javax.swing.KeyStroke definition code for javax.swing.KeyStroke  key)
Removes the binding for key from this InputMap.


clear sample code for javax.swing.InputMap.clear() definition code for javax.swing.InputMap.clear()

public void clear()
Removes all the mappings from this InputMap.


keys sample code for javax.swing.InputMap.keys() definition code for javax.swing.InputMap.keys()

public KeyStroke sample code for javax.swing.KeyStroke definition code for javax.swing.KeyStroke [] keys()
Returns the KeyStrokes that are bound in this InputMap.


size sample code for javax.swing.InputMap.size() definition code for javax.swing.InputMap.size()

public int size()
Returns the number of KeyStroke bindings.


allKeys sample code for javax.swing.InputMap.allKeys() definition code for javax.swing.InputMap.allKeys()

public KeyStroke sample code for javax.swing.KeyStroke definition code for javax.swing.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.