Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.crosswire.common.swing
Class CWAction

    java.lang.Object
      javax.swing.AbstractAction
          org.crosswire.common.swing.CWAction

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

    public class CWAction

extends AbstractAction

A CrossWire Action is a generic extension of AbstractAction, that adds LARGE_ICON to Action and also forwards the Action to its listeners after modifying the ActionEvent to include the ACTION_COMMAND_KEY.

Author:
  DM Smith
See Also:
  `The GNU General Public License for details.`, Serialized Form

Field Summary
`static String` | `LARGE_ICON` The icon to display when a large one is needed.
`private EventListenerList` | `listeners`
`private static org.slf4j.Logger` | `log` The log stream
`private static long` | `serialVersionUID` Serialization ID
`static String` | `TOOL_TIP` The tooltip to display.

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
`CWAction()`

Method Summary
`void` | `actionPerformed(ActionEvent evt)` Forwards the ActionEvent to the registered listener.
`void` | `addActionListener(ActionListener listener)` Adds a listener for Action events.
`CWAction` | `clone()` Create a clone that does not copy the listeners.
`CWAction` | `enable(boolean newEnabled)` Set enabled either true or false on this action.
`private KeyStroke` | `getAccelerator(String acceleratorSpec)` Convert the string to a valid Accelerator (that is a KeyStroke)
`private KeyStroke` | `getKeyStroke(String acceleratorSpec)`
`void` | `removeActionListener(ActionListener listener)` Remove an ActionListener
`CWAction` | `setAccelerator(String acceleratorSpec)` Set the accelerator key from spec.
`CWAction` | `setLargeIcon(Icon icon)` Set or clear, using null, the icon on this action.
`CWAction` | `setLargeIcon(String iconPath)`
`CWAction` | `setListener(ActionListener listener)` Create a clone of this action and attache the listener.
`CWAction` | `setSmallIcon(Icon icon)` Set or clear, using null, the icon on this action.
`CWAction` | `setSmallIcon(String iconPath)`
`CWAction` | `setTooltip(String tooltip)`
`String` | `toString()` String representation of this object suitable for debugging

Methods inherited from class javax.swing.AbstractAction
`addPropertyChangeListener, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### LARGE_ICON

    public static final String LARGE_ICON

  The icon to display when a large one is needed. This is still not part of Java as of 1.5. Now it is with Java 1.6!

  See Also:
    Constant Field Values

### TOOL_TIP

    public static final String TOOL_TIP

  The tooltip to display. This is an alias for SHORT_DESCRIPTION. The creator and user of a CWAction is to store and retrieve SHORT_DESCRIPTION.

  See Also:
    Constant Field Values

### listeners

    private EventListenerList listeners

### log

    private static final org.slf4j.Logger log

  The log stream

### serialVersionUID

    private static final long serialVersionUID

  Serialization ID

  See Also:
    Constant Field Values

Constructor Detail

### CWAction

    public CWAction()

Method Detail

### setLargeIcon

    public CWAction setLargeIcon(Icon icon)

  Set or clear, using null, the icon on this action.

  Parameters:
    `icon` - the small icon to set
  Returns:
    this action

### setLargeIcon

    public CWAction setLargeIcon(String iconPath)

### setTooltip

    public CWAction setTooltip(String tooltip)

### setSmallIcon

    public CWAction setSmallIcon(Icon icon)

  Set or clear, using null, the icon on this action.

  Parameters:
    `icon` - the small icon to set
  Returns:
    this action

### setSmallIcon

    public CWAction setSmallIcon(String iconPath)

### setAccelerator

    public CWAction setAccelerator(String acceleratorSpec)

  Set the accelerator key from spec. If the spec is invalid it is logged and ignored.

  Parameters:
    `acceleratorSpec` -
  Returns:
    this action

### enable

    public CWAction enable(boolean newEnabled)

  Set enabled either true or false on this action.

  Parameters:
    `newEnabled` - the desired state
  Returns:
    this action

### setListener

    public CWAction setListener(ActionListener listener)

  Create a clone of this action and attache the listener. If no listener is supplied, the action is not cloned.

  Parameters:
    `listener` - the listener for the action
  Returns:
    a cloned action with the listener attached or the current action

### actionPerformed

    public void actionPerformed(ActionEvent evt)

  Forwards the ActionEvent to the registered listener.

  Parameters:
    `evt` - ActionEvent

### addActionListener

    public void addActionListener(ActionListener listener)

  Adds a listener for Action events.

  Parameters:
    `listener` - `ActionListener` to add

### removeActionListener

    public void removeActionListener(ActionListener listener)

  Remove an ActionListener

  Parameters:
    `listener` - `ActionListener` to remove

### toString

    public String toString()

  String representation of this object suitable for debugging

  Overrides:
    `toString` in class `Object`

### clone

    public CWAction clone()

  Create a clone that does not copy the listeners. These CWActions need to have listeners added to be meaningful.

  Overrides:
    `clone` in class `AbstractAction`
  See Also:
    `AbstractAction.clone()`

### getAccelerator

    private KeyStroke getAccelerator(String acceleratorSpec)

  Convert the string to a valid Accelerator (that is a KeyStroke)

### getKeyStroke

    private KeyStroke getKeyStroke(String acceleratorSpec)
                            throws NumberFormatException

  Throws:
    `NumberFormatException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Copyright ¨ 2003-2015
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD