public enum Modifiers extends Enum<Modifiers>
An enumeration class representing special modifier keys.
A typical key board contains some special modifier keys that can be pressed together with other keys modifying their state and meaning, e.g. the SHIFT or the ALT key. This class defines constants for such keys. Most UI toolkits define similar constants. This enumeration class provides a portable way of specifying such modifiers.
The constants defined by this class can be used by several other classes in the JGUIraffe library. For instance, accelerators for actions (i.e. key board short cuts) may be assigned some modifiers that need to be pressed for activating the accelerator. When a mouse event is received, it is also possible to query the status of the modifier keys.
Tip: When working with modifiers often sets are needed
because other objects (e.g. accelerators) can be associated with an arbitrary
number of modifiers. In such cases the java.util.EnumSet
class can be
used. It provides convenience methods for creating sets containing specific
combinations of Modifiers
constants. The following code fragment
demonstrates how such a set can be obtained:
EnumSet<Modifiers> mods = EnumSet.of(Modifiers.ALT, Modifiers.SHIFT);
Enum Constant and Description |
---|
ALT
Constant representing the ALT modifier key.
|
ALT_GRAPH
Constant representing the ALT GRAPH modifier key.
|
CONTROL
Constant representing the CONTROL modifier key.
|
META
Constant representing the META modifier key.
|
SHIFT
Constant representing the SHIFT modifier key.
|
Modifier and Type | Method and Description |
---|---|
static Modifiers |
fromString(String s)
Tries to find a
Modifiers constant for the specified string. |
static Modifiers |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Modifiers[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Modifiers ALT
public static final Modifiers ALT_GRAPH
public static final Modifiers CONTROL
public static final Modifiers META
public static final Modifiers SHIFT
public static Modifiers[] values()
for (Modifiers c : Modifiers.values()) System.out.println(c);
public static Modifiers valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static Modifiers fromString(String s)
Modifiers
constant for the specified string. The
string is compared with the constants defined in this class ignoring
case. If a match is found, the corresponding Modifiers
constant
is returned. Otherwise, an exception is thrown.s
- the string to be parsedModifiers
constantIllegalArgumentException
- if no match can be foundCopyright © 2016 The JGUIraffe Team. All rights reserved.