- 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
-
-
Constructor Summary
Constructors Constructor and Description InputMap()Creates anInputMapwith no parent and no mappings.
-
Method Summary
Methods Modifier and Type Method and 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
-
setParent
public void setParent(InputMap map)
Sets thisInputMap's parent.- Parameters:
map- theInputMapthat is the parent of this one
-
getParent
public InputMap getParent()
Gets thisInputMap's parent.- Returns:
- map the
InputMapthat is the parent of this one, or null if thisInputMaphas no parent
-
put
public void put(KeyStroke keyStroke, Object actionMapKey)
Adds a binding forkeyStroketoactionMapKey. IfactionMapKeyis null, this removes the current binding forkeyStroke.
-
get
public Object get(KeyStroke keyStroke)
Returns the binding forkeyStroke, messaging the parentInputMapif the binding is not locally defined.
-
remove
public void remove(KeyStroke key)
Removes the binding forkeyfrom thisInputMap.
-
clear
public void clear()
Removes all the mappings from thisInputMap.
-
keys
public KeyStroke[] keys()
Returns theKeyStrokes that are bound in thisInputMap.
-
size
public int size()
Returns the number ofKeyStrokebindings.
-
allKeys
public 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.
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
07/10/2025 00:48:32 Cette version de la page est en cache (à la date du 07/10/2025 00:48:32) afin d'accélérer le traitement.Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.
Document créé le 30/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/swing/inputmap.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.