|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jguiraffe.gui.builder.action.Accelerator
public class Accelerator
A class that represents an accelerator for invoking an action.
An accelerator is a key (or a combination of keys, typically associated with
some modifier keys like SHIFT or ALT) that triggers an action when pressed.
Thus it is a keyboard short cut that has the same effect as clicking a tool
bar button or selecting a menu element. When a
is created (defined by an
FormAction object) an accelerator can be specified. This
can have effect on GUI elements associated with this action. For instance,
menus will typically display the keyboard combinations that correspond to the
menu elements.
ActionData
This class has the same purpose as javax.swing.KeyStroke:
serving as an abstract description of a combination of key presses. However,
it is more tailored towards the builder approach followed by this library.
This means that the main use case of this class is being created indirectly
in a builder script (mostly using a text representation) and then being
passed to an implementation of ActionManager. A concrete
ActionManager implementation is responsible for converting a
generic Accelerator object into a platform-specific
representation of a key stroke.
Instances of this class store a set of modifiers (like SHIFT or CONTROL) that must be pressed together with the key. The actual key can be specified in the following different ways:
getKey() method, which returns a Character.getSpecialKey() method will return a non-null value.VK_XXX constants
of the KeyEvent class). If such a code is set, it can be queried
using the getKeyCode() method. Note that this variant is not
portable.Implementation note: Instances of this class are immutable and can be shared among multiple threads.
| Method Summary | |
|---|---|
boolean |
equals(java.lang.Object obj)
Compares this object with another one. |
static Accelerator |
getInstance(java.lang.Character key,
java.util.Set<Modifiers> modifiers)
Returns an Accelerator for the specified printable key and
the (optional) modifiers. |
static Accelerator |
getInstance(java.lang.Integer keyCode,
java.util.Set<Modifiers> modifiers)
Returns an Accelerator for the specified platform-specific
key code and the (optional) modifiers. |
static Accelerator |
getInstance(Keys key,
java.util.Set<Modifiers> modifiers)
Returns an Accelerator for the specified special key and the
(optional) modifiers. |
java.lang.Character |
getKey()
Returns the character. |
java.lang.Integer |
getKeyCode()
Returns the key code. |
java.util.Set<Modifiers> |
getModifiers()
Returns a set with the modifiers set for this accelerator. |
Keys |
getSpecialKey()
Returns the special key. |
int |
hashCode()
Returns a hash code for this object. |
static Accelerator |
parse(java.lang.String s)
Returns an Accelerator instance from the specified string
representation. |
java.lang.String |
toString()
Returns a string representation of this object. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public java.util.Set<Modifiers> getModifiers()
public Keys getSpecialKey()
public java.lang.Character getKey()
public java.lang.Integer getKeyCode()
public java.lang.String toString()
parse(String)
method, i.e. they can be used for creating Accelerator
instances. They are normalized in the following way:
enum constants are declared and happens to be
alphabetic order).
toString in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the object to compare
public int hashCode()
hashCode in class java.lang.Object
public static Accelerator getInstance(Keys key,
java.util.Set<Modifiers> modifiers)
Accelerator for the specified special key and the
(optional) modifiers.
key - the special key for this accelerator (must not be null)modifiers - a set with modifiers (can be null)
Accelerator instance
java.lang.IllegalArgumentException - if the key is undefined
public static Accelerator getInstance(java.lang.Character key,
java.util.Set<Modifiers> modifiers)
Accelerator for the specified printable key and
the (optional) modifiers.
key - the character for this accelerator (must not be null)modifiers - a set with modifiers (can be null)
Accelerator instance
java.lang.IllegalArgumentException - if the key is undefined
public static Accelerator getInstance(java.lang.Integer keyCode,
java.util.Set<Modifiers> modifiers)
Accelerator for the specified platform-specific
key code and the (optional) modifiers.
key - the special key code for this accelerator (must not be
null)modifiers - a set with modifiers (can be null)
Accelerator instance
java.lang.IllegalArgumentException - if the key is undefinedpublic static Accelerator parse(java.lang.String s)
Returns an Accelerator instance from the specified string
representation. The string must be a valid representation of an
Accelerator instance as it is returned by the
toString() method. Otherwise an
IllegalArgumentException exception will be thrown.
Valid strings have the following form:
acceleratorString ::= (<modifier>)* keySpec keySpec ::= <character> | <specialKey> | <keyCode>With other words: The string can contain multiple components all separated by whitespace. The last component defines the actual keys, all others are interpreted as modifiers. They must conform to literals of the
Modifiers enumeration (case does not matter). For the last
component, there are the following possibilities:
Keys enumeration, the
corresponding special key is set (the comparison is not case sensitive).Here are some examples:
"A"control AShift CONTROL AAlt BackspaceF142CONTROL 5CONTROL 05If the whole string is null or empty, null is returned.
s - the string to be parsed (can be null)
Accelerator instance
java.lang.IllegalArgumentException - if the string cannot be parsed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||