|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectKeyInfo
public class KeyInfo
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
and modifiers
taken from
constants in the KeyEvent class:
KeyInfo left = new KeyInfo(KeyEvent.VK_LEFT, 0, "Left");
KeyInfo shiftUp = new KeyInfo(KeyEvent.VK_UP, KeyEvent.SHIFT_DOWN_MASK, "Shift+Up");
The String argument can later be retrieved with toString()
and can be useful for GUI elements such as menu items.
Constructor Summary | |
---|---|
KeyInfo(int keyCode,
int modifiers,
String desc)
Creates a new instance. |
|
KeyInfo(KeyInfo keyInfo)
Creates a copy of an existing instance. |
Method Summary | |
---|---|
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 this KeyInfo
match that of a given KeyEvent . |
String |
toString()
Gets the short text description for this object. |
Methods inherited from class Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public KeyInfo(int keyCode, int modifiers, String desc)
desc
is null
or empty,
the description will be set to "KeyInfo(keyCode, modifiers)".
keyCode
- key codemodifiers
- modifiers (0 for none)desc
- short description suitable for GUI labels etc.public KeyInfo(KeyInfo keyInfo)
keyInfo
- the instance to copy
IllegalArgumentException
- if keyInfo
is null
Method Detail |
---|
public int getKeyCode()
public int getModifiers()
public String toString()
toString
in class Object
public boolean matchesEvent(KeyEvent e)
KeyInfo
match that of a given KeyEvent
. For convenience, this
method will return false
if the input event is null
.
e
- the input event
true
if the key code and modifier values match those
of the input eventpublic boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |