edu.princeton.swing
Class AbstractAction2

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by edu.princeton.swing.AbstractAction2
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
Direct Known Subclasses:
ActionedUndoManager.RedoAction, ActionedUndoManager.UndoAction, ClipboardTargetManager.CopyAction, ClipboardTargetManager.CutAction, ClipboardTargetManager.PasteAction, ClipboardTargetManager.SelectAllAction, TFrame.TFrameAction, TOptionsFrame.FileHistoryAction, TOptionsFrame.OptionsAction

public abstract class AbstractAction2
extends AbstractAction

AbstractAction2 extends action to provide convenient get/set methods as well as a method to create a JMenuItem from this action.

See Also:
Serialized Form

Field Summary
static String EXTRA_INFO_KEY
          The key used for storing a random object containing extraneous information.
static String LONG_DESCRIPTION_KEY
          The key used for storing a longer description for the action, could be used for context-sensitive help.
static String NAME_KEY
          The key used for storing the name for the action, used for a menu or button.
static String SHORT_DESCRIPTION_KEY
          The key used for storing a short description for the action, used for tooltip text.
static String SMALL_ICON_KEY
          The key used for storing a small icon for the action, used for toolbar buttons.
 
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
AbstractAction2()
          Creates a new AbstractAction2.
AbstractAction2(String name)
          Creates a new AbstractAction2.
AbstractAction2(String name, Icon icon)
          Creates a new AbstractAction2.
 
Method Summary
 JMenuItem createMenuItem()
          Creates a new JMenuItem for this Action.
 KeyStroke getAccelerator()
          Gets the accelerator keystroke for this Action.
 String getActionCommand()
          Gets the action command for this Action.
 Object getExtraInfo()
          Gets the extra info for this Action.
 String getLongDescription()
          Gets the long description for this Action.
 int getMnemonic()
          Gets the mnemonic key for this Action.
 String getName()
          Gets the name of this Action.
 String getShortDescription()
          Gets the short description for this Action.
 Icon getSmallIcon()
          Gets the small icon for this Action.
 void setAccelerator(KeyStroke accelerator)
          Sets the accelerator keystroke for this Action.
 void setActionCommand(String command)
          Sets the action command for this Action.
 void setExtraInfo(Object extraInfo)
          Sets the extra info for this Action.
 void setLongDescription(String description)
          Sets the long description for this Action.
 void setMnemonic(int mnemonic)
          Sets the mnemonic key for this Action.
 void setName(String name)
          Sets the name of this Action.
 void setShortDescription(String description)
          Sets the short description for this Action.
 void setSmallIcon(Icon icon)
          Sets the small icon for this Action.
 
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
 
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
 

Field Detail

NAME_KEY

public static final String NAME_KEY
The key used for storing the name for the action, used for a menu or button.

See Also:
Constant Field Values

SMALL_ICON_KEY

public static final String SMALL_ICON_KEY
The key used for storing a small icon for the action, used for toolbar buttons.

See Also:
Constant Field Values

SHORT_DESCRIPTION_KEY

public static final String SHORT_DESCRIPTION_KEY
The key used for storing a short description for the action, used for tooltip text.

See Also:
Constant Field Values

LONG_DESCRIPTION_KEY

public static final String LONG_DESCRIPTION_KEY
The key used for storing a longer description for the action, could be used for context-sensitive help.

See Also:
Constant Field Values

EXTRA_INFO_KEY

public static final String EXTRA_INFO_KEY
The key used for storing a random object containing extraneous information.

See Also:
Constant Field Values
Constructor Detail

AbstractAction2

public AbstractAction2()
Creates a new AbstractAction2.


AbstractAction2

public AbstractAction2(String name)
Creates a new AbstractAction2.


AbstractAction2

public AbstractAction2(String name,
                       Icon icon)
Creates a new AbstractAction2.

Method Detail

getName

public String getName()
Gets the name of this Action. A value of null indicates that this Action does not have a name.

Returns:
The name for this Action.

setName

public void setName(String name)
Sets the name of this Action. A value of null indicates that this Action should not have a name.

Parameters:
name - The name of this Action.

getSmallIcon

public Icon getSmallIcon()
Gets the small icon for this Action. A value of null indicates that this Action does not have a small icon.

Returns:
The small icon for this Action.

setSmallIcon

public void setSmallIcon(Icon icon)
Sets the small icon for this Action. A value of null indicates that this Action should not have a small icon.

Parameters:
icon - The small icon for this Action.

getShortDescription

public String getShortDescription()
Gets the short description for this Action. A value of null indicates that this Action does not have a short description.

Returns:
The short description for this Action.

setShortDescription

public void setShortDescription(String description)
Sets the short description for this Action. A value of null indicates that this Action should not have a short description.

Parameters:
description - The short description for this Action.

getLongDescription

public String getLongDescription()
Gets the long description for this Action. A value of null indicates that this Action does not have a long description.

Returns:
The long description for this Action.

setLongDescription

public void setLongDescription(String description)
Sets the long description for this Action. A value of null indicates that this Action should not have a long description.

Parameters:
description - The long description for this Action.

getMnemonic

public int getMnemonic()
Gets the mnemonic key for this Action. A value of 0 indicates that this Action does not have a mnemonic key.

Returns:
The mnemonic key for this Action.

setMnemonic

public void setMnemonic(int mnemonic)
Sets the mnemonic key for this Action. A value of 0 indicates that this Action should not have a mnemonic key.

Parameters:
mnemonic - The mnemonic for this action (This should be one of the KeyEvent.VK_x constants).

getAccelerator

public KeyStroke getAccelerator()
Gets the accelerator keystroke for this Action. A value of null indicates that this Action does not have an accelerator keystroke.

Returns:
The accelerator keystroke for this Action.

setAccelerator

public void setAccelerator(KeyStroke accelerator)
Sets the accelerator keystroke for this Action. A value of null indicates that this Action should not have an accelerator keystroke.

Parameters:
accelerator - The accelerator for this Action.

getActionCommand

public String getActionCommand()
Gets the action command for this Action. A value of null indicates that this Action does not have an action command.

Returns:
The action command for this Action.

setActionCommand

public void setActionCommand(String command)
Sets the action command for this Action. A value of null indicates that this Action should not have an action command.

Parameters:
command - The action command for this Action.

getExtraInfo

public Object getExtraInfo()
Gets the extra info for this Action. A value of null indicates that this Action does not have any extra info.

Returns:
The extra info for this Action.

setExtraInfo

public void setExtraInfo(Object extraInfo)
Sets the extra info for this Action. A value of null indicates that this Action should not have any extra info.

Parameters:
extraInfo - The extra info for this Action.

createMenuItem

public JMenuItem createMenuItem()
Creates a new JMenuItem for this Action. This method ensures that the JMenuItem has the correct accelerator (the JVM for OS X has problems with this).

Parameters:
A - JMenuItem whose action is this action.