Package org.geotools.swing.event
Class KeyInfo
- Object
-
- KeyInfo
-
public class KeyInfo extends Object
Represents a keyboard key or key combination. It is used by MapPaneKeyHandler to store key bindings associated with map pane actions.You create instances using values of
keyCode
andmodifiers
taken from constants in the KeyEvent class:
The String argument can later be retrieved with toString() and can be useful for GUI elements such as menu items.KeyInfo left = new KeyInfo(KeyEvent.VK_LEFT, 0, "Left"); KeyInfo shiftUp = new KeyInfo(KeyEvent.VK_UP, KeyEvent.SHIFT_DOWN_MASK, "Shift+Up");
- Since:
- 8.0
- Author:
- Michael Bedward
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
int
getKeyCode()
Gets the key code.int
getModifiers()
Gets the modifiers.int
hashCode()
boolean
matchesEvent(KeyEvent e)
Tests whether the key code and modifiers of thisKeyInfo
match that of a givenKeyEvent
.String
toString()
Gets the short text description for this object.
-
-
-
Constructor Detail
-
KeyInfo
public KeyInfo(int keyCode, int modifiers, String desc)
Creates a new instance. Ifdesc
isnull
or empty, the description will be set to "KeyInfo(keyCode, modifiers)".- Parameters:
keyCode
- key codemodifiers
- modifiers (0 for none)desc
- short description suitable for GUI labels etc.
-
KeyInfo
public KeyInfo(KeyInfo keyInfo)
Creates a copy of an existing instance.- Parameters:
keyInfo
- the instance to copy- Throws:
IllegalArgumentException
- ifkeyInfo
isnull
-
-
Method Detail
-
getKeyCode
public int getKeyCode()
Gets the key code.- Returns:
- the key code
-
getModifiers
public int getModifiers()
Gets the modifiers.- Returns:
- the modifiers
-
toString
public String toString()
Gets the short text description for this object. This can be useful for GUI labels, menu items etc.
-
matchesEvent
public boolean matchesEvent(KeyEvent e)
Tests whether the key code and modifiers of thisKeyInfo
match that of a givenKeyEvent
. For convenience, this method will returnfalse
if the input event isnull
.- Parameters:
e
- the input event- Returns:
true
if the key code and modifier values match those of the input event
-
-