ToggleAction
vmm3d.actions

Class ToggleAction

  • All Implemented Interfaces:
    ActionListener, Serializable, Cloneable, EventListener, Action, ActionItem


    public class ToggleActionextends AbstractActionVMM
    A ToggleAction is an Action that has a boolean-valued property named "ToggleState". The createCheckBox() and createCheckBoxMenuItem() methods return components whose state is synchronized with each other and with the state of this ToggleAction. When one of these components generates an ActionEvent, the states of the ToggleAction and of all the synchronized components are changed to match. A getState() method is provided as a convenience to make it possible to determine the current state. (Note that this is a concrete subclass of AbstractAction, but its actionPerformed method is defined to do nothing. It is still possible to override this method if you want to perform some action when the state changes.)
    See Also:
    Serialized Form
    • Constructor Detail

      • ToggleAction

        public ToggleAction()
        Create a ToggleAction with no name or icon and initial state set to false.
      • ToggleAction

        public ToggleAction(String name)
        Create a ToggleAction with a given name but no icon and initial state set to false.
        Parameters:
        name - If non-null, this string will be set as the Name property of the Action.
      • ToggleAction

        public ToggleAction(String name,            boolean checked)
        Create a ToggleAction with a specified name and initial state, and no icon.
        Parameters:
        name - If non-null, this string will be set as the Name property of the Action.
        checked - The initial value of the "ToggleState" property.
      • ToggleAction

        public ToggleAction(String name,            Icon icon)
        Create a ToggleAction with a specified name and icon and with state initially set to false.
        Parameters:
        name - If non-null, this string will be set as the Name property of the Action.
        icon - If non-null this icon will be set as the Icon property of the Action.
    • Method Detail

      • actionPerformed

        public void actionPerformed(ActionEvent evt)
        This method implements the abstract method that is inherited from the AbstractAction class, but it is defined to do nothing. If you want to perform some action when the state of the ToggleAction is changed because of a user action, you can override this method. Note that this method is NOT called when the state is changed programmatically.
      • getState

        public boolean getState()
        Gets the current state of the ToggleAction. This is just the boolean value associated with the "ToggleState" property of the Action.
      • setState

        public void setState(boolean state)
        Sets the current state of the ToggleAction. The state is just the "ToggleState" property of the Action; this method is just a convenience method that sets that property.
      • createCheckBoxMenuItem

        public JCheckBoxMenuItem createCheckBoxMenuItem()
        Return a JCheckBoxMenuItem whose selection state is synchronized with the state of this ToggleAction and with other components returned by this method and by createCheckBox().
      • createCheckBox

        public JCheckBox createCheckBox()
        Return a JCheckBox whose selection state is synchronized with the state of this ToggleAction and with other components returned by this method and by createCheckBoxMenuItem().

SCaVis 1.7 © jWork.org