Class Action


  • public abstract class Action
    extends java.lang.Object
    Abstract base class for "actions". Actions are common application behaviors generally triggered by buttons, menu items, and keyboard shortcuts.
    • Constructor Detail

      • Action

        public Action()
        Constructor which builds the action and sets it enabled to begin with.
      • Action

        public Action​(boolean initialEnable)
        Constructor to build the action and set the enabled state at the beginning.
        Parameters:
        initialEnable - Whether the action is to be initially enabled.
    • Method Detail

      • getDescription

        public java.lang.String getDescription()
        Returns a text description of the action. Subclasses should override this to return a meaningful description if one is needed.
        Returns:
        The text description of the action.
      • perform

        public abstract void perform​(Component source)
        Performs the action.
        Parameters:
        source - The component that initiated the action.
      • performAction

        public static void performAction​(java.lang.String actionName,
                                         Component comp)
        Perform the named action, unless the action is disabled.

        This is the equivalent of Action.getNamedActions().get(actionName).perform(comp).

        Parameters:
        actionName - One of the previously defined action names.
        comp - The component initiating the action.
        Throws:
        java.lang.IllegalArgumentException - if the actionName is null or if there is no action with that name.
      • performAction

        public static <E extends java.lang.Enum<E>> void performAction​(E actionName,
                                                                       Component comp)
        Perform the named action, unless the action is disabled.

        This is the equivalent of Action.getNamedActions().get(actionName).perform(comp).

        Type Parameters:
        E - Enum type that gives the action name.
        Parameters:
        actionName - An enum value whose toString() value is used as the action name.
        comp - The component initiating the action.
        Throws:
        java.lang.IllegalArgumentException - if the actionName is null or if there is no action with that name.
      • isEnabled

        public boolean isEnabled()
        Check if this action is currently enabled.
        Returns:
        Whether or not this action is currently enabled.
        See Also:
        setEnabled(boolean)
      • addNamedAction

        public static Action addNamedAction​(java.lang.String actionName,
                                            Action action)
        Add this action to the named action dictionary.

        This is equivalent to getNamedActions().put(actionName, action)

        Parameters:
        actionName - The name to store this action under (can be referenced from button actions, etc.)
        action - The action to be performed under this name.
        Returns:
        The previous action (if any) listed under this name.
      • addNamedAction

        public static <E extends java.lang.Enum<E>> Action addNamedAction​(E actionName,
                                                                          Action action)
        Add this action to the named action dictionary.

        This is equivalent to getNamedActions().put(actionName, action)

        Type Parameters:
        E - Enum type that gives the action name.
        Parameters:
        actionName - An enum whose toString() value is used as the ID for the action.
        action - The action to be performed under this name.
        Returns:
        The previous action (if any) listed under this name.
        Throws:
        java.lang.IllegalArgumentException - if the actionName is null.
      • getNamedAction

        public static Action getNamedAction​(java.lang.String actionName)
        Get the named action from the dictionary.

        This is the equivalent of getNamedActions().get(actionName)

        Parameters:
        actionName - The name this action was stored under in the dictionary.
        Returns:
        The action currently associated with this name (or null if there is no saved action with that name value).
      • getNamedAction

        public static <E extends java.lang.Enum<E>> Action getNamedAction​(E actionName)
        Get the named action from the dictionary.

        This is the equivalent of getNamedActions().get(actionName)

        Type Parameters:
        E - Enum type that gives the action name.
        Parameters:
        actionName - An enum whose toString() method is used as the ID for the action.
        Returns:
        The action currently associated with this name (or null if there is no saved action with that name value).
        Throws:
        java.lang.IllegalArgumentException - if the actionName is null.
      • getActionClassListeners

        public static ListenerList<ActionClassListener> getActionClassListeners()
        Returns:
        The list of listeners for all action activities.