gov.nasa.gsfc.drl.rtstps.library
Class XAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by gov.nasa.gsfc.drl.rtstps.library.XAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
Direct Known Subclasses:
AbstractCommandAction, ExitAction, StatusTableAction, StatusWindowAction, ZeroAction

public abstract class XAction
extends javax.swing.AbstractAction
implements java.awt.event.ActionListener

This class is an extension to AbstractAction. It adds some useful methods that are not in AbstractAction, and I take advantage of them when I make toolbars and menus. AbstractAction uses the technique of storing attributes with text keys in a map, which always seemed silly to me when you have a perfectly good convention of set/get method calls.

See Also:
Serialized Form

Field Summary
private  java.lang.String label
           
private static long serialVersionUID
           
 
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
protected XAction(java.lang.String label)
          Define an Action object with the specified label and a default icon.
protected XAction(java.lang.String label, javax.swing.Icon icon)
          Define an Action object with the specified label and icon.
 
Method Summary
abstract  void actionPerformed(java.awt.event.ActionEvent e)
          The action that is performed when the button is pressed or the menu item is selected.
abstract  javax.swing.KeyStroke getKeyStroke()
          Get a hotkey combination that activates the action.
abstract  char getMnemonic()
          Get the mnemonic character associated with the action label.
 java.lang.String getText()
          Get the text associated with this action.
abstract  java.lang.String getToolTip()
          Get the action's tooltip.
 
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

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

label

private java.lang.String label
Constructor Detail

XAction

protected XAction(java.lang.String label,
                  javax.swing.Icon icon)
Define an Action object with the specified label and icon.


XAction

protected XAction(java.lang.String label)
Define an Action object with the specified label and a default icon.

Method Detail

getText

public final java.lang.String getText()
Get the text associated with this action.

Returns:
label

getMnemonic

public abstract char getMnemonic()
Get the mnemonic character associated with the action label.

Returns:
the mnemonic character or null if there is none.

getToolTip

public abstract java.lang.String getToolTip()
Get the action's tooltip.

Returns:
a tooltip string or null if there is none.

getKeyStroke

public abstract javax.swing.KeyStroke getKeyStroke()
Get a hotkey combination that activates the action. Here's an example that links control-A to the action.
  public KeyStroke getKeyStroke()
  {
      return KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A,
               java.awt.event.InputEvent.CTRL_MASK);
  }
 

Returns:
the associated keystroke combination

actionPerformed

public abstract void actionPerformed(java.awt.event.ActionEvent e)
The action that is performed when the button is pressed or the menu item is selected.

Specified by:
actionPerformed in interface java.awt.event.ActionListener