FileDocCategorySizeDatePackage
ComponentInputMap.javaAPI DocJava SE 6 API3104Tue Jun 10 00:26:34 BST 2008javax.swing

ComponentInputMap

public class ComponentInputMap extends InputMap
A ComponentInputMap is an InputMap associated with a particular JComponent. The component is automatically notified whenever the ComponentInputMap changes. ComponentInputMaps are used for WHEN_IN_FOCUSED_WINDOW bindings.
version
1.11 04/07/06
author
Scott Violet
since
1.3

Fields Summary
private JComponent
component
Component binding is created for.
Constructors Summary
public ComponentInputMap(JComponent component)
Creates a ComponentInputMap associated with the specified component.

param
component a non-null JComponent
throws
IllegalArgumentException if component is null

	this.component = component;
	if (component == null) {
	    throw new IllegalArgumentException("ComponentInputMaps must be associated with a non-null JComponent");
	}
    
Methods Summary
public voidclear()
Removes all the mappings from this object.

	int oldSize = size();
	super.clear();
	if (oldSize > 0 && getComponent() != null) {
	    getComponent().componentInputMapChanged(this);
	}
    
public javax.swing.JComponentgetComponent()
Returns the component the InputMap was created for.

	return component;
    
public voidput(javax.swing.KeyStroke keyStroke, java.lang.Object actionMapKey)
Adds a binding for keyStroke to actionMapKey. If actionMapKey is null, this removes the current binding for keyStroke.

	super.put(keyStroke, actionMapKey);
	if (getComponent() != null) {
	    getComponent().componentInputMapChanged(this);
	}
    
public voidremove(javax.swing.KeyStroke key)
Removes the binding for key from this object.

	super.remove(key);
	if (getComponent() != null) {
	    getComponent().componentInputMapChanged(this);
	}
    
public voidsetParent(javax.swing.InputMap map)
Sets the parent, which must be a ComponentInputMap associated with the same component as this ComponentInputMap.

param
map a ComponentInputMap
throws
IllegalArgumentException if map is not a ComponentInputMap or is not associated with the same component

	if (getParent() == map) {
	    return;
	}
	if (map != null && (!(map instanceof ComponentInputMap) ||
		 ((ComponentInputMap)map).getComponent() != getComponent())) {
	    throw new IllegalArgumentException("ComponentInputMaps must have a parent ComponentInputMap associated with the same component");
	}
	super.setParent(map);
	getComponent().componentInputMapChanged(this);