Enum Modifiers

  • All Implemented Interfaces:
    Serializable, Comparable<Modifiers>

    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);
     

    Version:
    $Id: Modifiers.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Enum Constant Detail

      • ALT

        public static final Modifiers ALT
        Constant representing the ALT modifier key.
      • ALT_GRAPH

        public static final Modifiers ALT_GRAPH
        Constant representing the ALT GRAPH modifier key.
      • CONTROL

        public static final Modifiers CONTROL
        Constant representing the CONTROL modifier key.
      • META

        public static final Modifiers META
        Constant representing the META modifier key.
      • SHIFT

        public static final Modifiers SHIFT
        Constant representing the SHIFT modifier key.
    • Method Detail

      • values

        public static Modifiers[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Modifiers c : Modifiers.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Modifiers valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • fromString

        public static Modifiers fromString​(String s)
        Tries to find a 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.
        Parameters:
        s - the string to be parsed
        Returns:
        the corresponding Modifiers constant
        Throws:
        IllegalArgumentException - if no match can be found