DESY ACOP Beans Home

com.cosylab.gui.components.util
Class ToggleAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by com.cosylab.gui.components.util.ToggleAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action

public class ToggleAction
extends javax.swing.AbstractAction

An extension of the javax.swing.Action interface which provides selected bound property. It can be used to specify an action which switches between two different states. GUI components will render these actions with check boxes or toggle buttons.

To use this action, either instantiate this class and register as a propertyChangeListener, responding to events that denote a change in "selected" property, or extend this class, overriding actionPerformed() method.

Version:
$id$
Author:
Miha Kadunc
See Also:
Serialized Form

Field Summary
static java.lang.String LARGE_SELECTED_ICON
          Large icon used when the action is selected
static java.lang.String SMALL_SELECTED_ICON
          Icon used when the action is selected
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
ToggleAction()
          Constructor with default values.
ToggleAction(java.lang.String name)
          Constructor with name.
ToggleAction(java.lang.String name, boolean selected)
          Constructor with name and selection flag.
ToggleAction(java.lang.String name, javax.swing.Icon icon)
          Contructor with name and icon.
ToggleAction(java.lang.String name, javax.swing.Icon icon, boolean selected)
          Contructor with name, icon and selection flag.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Overriden to modify selection status.
 boolean isSelected()
           
protected  void selectionChanged(boolean selected)
          Override this method to provide custom event handling when selection changes.
 void setSelected(boolean selected)
          Sets the selected property.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SMALL_SELECTED_ICON

public static final java.lang.String SMALL_SELECTED_ICON
Icon used when the action is selected

See Also:
Constant Field Values

LARGE_SELECTED_ICON

public static final java.lang.String LARGE_SELECTED_ICON
Large icon used when the action is selected

See Also:
Constant Field Values
Constructor Detail

ToggleAction

public ToggleAction()
Constructor with default values.


ToggleAction

public ToggleAction(java.lang.String name)
Constructor with name.

Parameters:
name - the name of the action

ToggleAction

public ToggleAction(java.lang.String name,
                    boolean selected)
Constructor with name and selection flag.

Parameters:
name - the name of the action
selected - the selection flag

ToggleAction

public ToggleAction(java.lang.String name,
                    javax.swing.Icon icon)
Contructor with name and icon.

Parameters:
name -
icon -

ToggleAction

public ToggleAction(java.lang.String name,
                    javax.swing.Icon icon,
                    boolean selected)
Contructor with name, icon and selection flag.

Parameters:
name - the name of action
icon - the icon to be used GUI element
selected - the selection flag
Method Detail

setSelected

public void setSelected(boolean selected)
Sets the selected property. Fires propertyChange events and calls actionPerformed() method with this as event source.

Parameters:
selected -

isSelected

public boolean isSelected()
Returns:
whether this toggle action is selected.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Overriden to modify selection status. Called by the GUI when invoked.


selectionChanged

protected void selectionChanged(boolean selected)
Override this method to provide custom event handling when selection changes.

Parameters:
newSelected -


Copyright © 2010. All Rights Reserved.