-
public interface Keymap
A collection of bindings of KeyStrokes to actions. The bindings are basically name-value pairs that potentially resolve in a hierarchy.
-
-
Method Summary
Methods Modifier and Type Method and Description void
addActionForKeyStroke(KeyStroke key, Action a)
Adds a binding to the keymap.Action
getAction(KeyStroke key)
Fetches the action appropriate for the given symbolic event sequence.Action[]
getBoundActions()
Fetches all of the actions defined in this keymap.KeyStroke[]
getBoundKeyStrokes()
Fetches all of the keystrokes in this map that are bound to some action.Action
getDefaultAction()
Fetches the default action to fire if a key is typed (i.e.KeyStroke[]
getKeyStrokesForAction(Action a)
Fetches the keystrokes that will result in the given action.String
getName()
Fetches the name of the set of key-bindings.Keymap
getResolveParent()
Fetches the parent keymap used to resolve key-bindings.boolean
isLocallyDefined(KeyStroke key)
Determines if the given key sequence is locally defined.void
removeBindings()
Removes all bindings from the keymap.void
removeKeyStrokeBinding(KeyStroke keys)
Removes a binding from the keymap.void
setDefaultAction(Action a)
Set the default action to fire if a key is typed.void
setResolveParent(Keymap parent)
Sets the parent keymap, which will be used to resolve key-bindings.
-
-
-
Method Detail
-
getName
String getName()
Fetches the name of the set of key-bindings.- Returns:
- the name
-
getDefaultAction
Action getDefaultAction()
Fetches the default action to fire if a key is typed (i.e. a KEY_TYPED KeyEvent is received) and there is no binding for it. Typically this would be some action that inserts text so that the keymap doesn't require an action for each possible key.- Returns:
- the default action
-
setDefaultAction
void setDefaultAction(Action a)
Set the default action to fire if a key is typed.- Parameters:
a
- the action
-
getAction
Action getAction(KeyStroke key)
Fetches the action appropriate for the given symbolic event sequence. This is used by JTextController to determine how to interpret key sequences. If the binding is not resolved locally, an attempt is made to resolve through the parent keymap, if one is set.- Parameters:
key
- the key sequence- Returns:
- the action associated with the key
sequence if one is defined, otherwise
null
-
getBoundKeyStrokes
KeyStroke[] getBoundKeyStrokes()
Fetches all of the keystrokes in this map that are bound to some action.- Returns:
- the list of keystrokes
-
getBoundActions
Action[] getBoundActions()
Fetches all of the actions defined in this keymap.- Returns:
- the list of actions
-
getKeyStrokesForAction
KeyStroke[] getKeyStrokesForAction(Action a)
Fetches the keystrokes that will result in the given action.- Parameters:
a
- the action- Returns:
- the list of keystrokes
-
isLocallyDefined
boolean isLocallyDefined(KeyStroke key)
Determines if the given key sequence is locally defined.- Parameters:
key
- the key sequence- Returns:
- true if the key sequence is locally defined else false
-
addActionForKeyStroke
void addActionForKeyStroke(KeyStroke key, Action a)
Adds a binding to the keymap.- Parameters:
key
- the key sequencea
- the action
-
removeKeyStrokeBinding
void removeKeyStrokeBinding(KeyStroke keys)
Removes a binding from the keymap.- Parameters:
keys
- the key sequence
-
removeBindings
void removeBindings()
Removes all bindings from the keymap.
-
getResolveParent
Keymap getResolveParent()
Fetches the parent keymap used to resolve key-bindings.- Returns:
- the keymap
-
setResolveParent
void setResolveParent(Keymap parent)
Sets the parent keymap, which will be used to resolve key-bindings. The behavior is unspecified if aKeymap
has itself as one of its resolve parents.- Parameters:
parent
- the parent keymap
-
-
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
22/12/2024 14:58:09 Cette version de la page est en cache (à la date du 22/12/2024 14:58:09) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 29/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/swing/text/keymap.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.