com.glaivestone.javax.swing
Class OperationAction

java.lang.Object
  |
  +--javax.swing.AbstractAction
        |
        +--com.glaivestone.javax.swing.OperationAction
All Implemented Interfaces:
javax.swing.Action, java.awt.event.ActionListener, java.lang.Cloneable, java.util.EventListener, java.io.Serializable

public class OperationAction
extends javax.swing.AbstractAction

A Swing Action which is configured to perform an operation.

Typically used to configure UI elements which invoke operations, such as push buttons, toolbar buttons, and pulldown/popup menu commands. Multiple UI elements can be attached to a single operation action to ensure consistent presentation of properties such as labelling, accelerator keys, and activation when an operation is made available in the UI in multiple ways.

Author:
Deb Lewis
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
OperationAction(java.lang.String name, java.awt.event.ActionListener operationHandler)
          Creates an action with the specified name which performs the operation configured by the given handler.
OperationAction(java.lang.String name, char mnemonic, java.awt.event.ActionListener operationHandler)
          Creates an action with the specified name which performs the operation configured by the given handler.
OperationAction(java.lang.String name, char mnemonic, java.lang.String shortDescription, java.awt.event.ActionListener operationHandler)
          Creates an action with the specified name which performs the operation configured by the given handler.
OperationAction(java.lang.String name, java.lang.String operationDescription, java.awt.event.ActionListener operationHandler)
          Creates an action with the specified name which performs the operation configured by the given handler.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Invoked when an action occurs.
 javax.swing.JMenuItem appendTo(javax.swing.JMenu aMenu)
          Append a menu item for this action to the menu.
 javax.swing.JMenuItem appendTo(javax.swing.JPopupMenu aMenu)
          Append a menu item for this action to the menu.
 void attachTo(javax.swing.JButton aButton)
          Deprecated. Use button setAction as of JDK 1.3
 void attachTo(javax.swing.JMenuItem aMenuItem)
          Attach this action to a menu item so its operation is performed when the menu item is selected.
 void installAccelerator(javax.swing.JMenuItem aComponent)
          Install the accelerator key combination for this operation on the UI element to which it is attached.
 void installMnemonic(javax.swing.AbstractButton aComponent)
          Install the mnemonic character for this operation on a button or menu item
 void installToolTip(javax.swing.JComponent aComponent)
          Install the tool tip for this operation on a button or menu item
 void setAccelerator(javax.swing.KeyStroke keyStroke)
          Specify the accelerator key combination for invoking the operation.
 void setDescription(java.lang.String operationDescription)
          Specify the description of the operation.
 void setMnemonic(char mnemonic)
          Specify the mnemonic character for this action.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperationAction

public OperationAction(java.lang.String name,
                       java.awt.event.ActionListener operationHandler)
Creates an action with the specified name which performs the operation configured by the given handler.


OperationAction

public OperationAction(java.lang.String name,
                       char mnemonic,
                       java.awt.event.ActionListener operationHandler)
Creates an action with the specified name which performs the operation configured by the given handler.


OperationAction

public OperationAction(java.lang.String name,
                       java.lang.String operationDescription,
                       java.awt.event.ActionListener operationHandler)
Creates an action with the specified name which performs the operation configured by the given handler. A short description of the operation is used for a tool tip on UI elements to which this action is attached.


OperationAction

public OperationAction(java.lang.String name,
                       char mnemonic,
                       java.lang.String shortDescription,
                       java.awt.event.ActionListener operationHandler)
Creates an action with the specified name which performs the operation configured by the given handler. A short description of the operation is used for a tool tip on UI elements to which this action is attached.

Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Invoked when an action occurs.

See Also:
ActionListener.actionPerformed(java.awt.event.ActionEvent)

appendTo

public javax.swing.JMenuItem appendTo(javax.swing.JMenu aMenu)
Append a menu item for this action to the menu.


appendTo

public javax.swing.JMenuItem appendTo(javax.swing.JPopupMenu aMenu)
Append a menu item for this action to the menu.


attachTo

public void attachTo(javax.swing.JButton aButton)
Deprecated. Use button setAction as of JDK 1.3

Attach this action to a button so its operation is performed when the button is clicked.


attachTo

public void attachTo(javax.swing.JMenuItem aMenuItem)
Attach this action to a menu item so its operation is performed when the menu item is selected.


installAccelerator

public void installAccelerator(javax.swing.JMenuItem aComponent)
Install the accelerator key combination for this operation on the UI element to which it is attached.


installMnemonic

public void installMnemonic(javax.swing.AbstractButton aComponent)
Install the mnemonic character for this operation on a button or menu item


installToolTip

public void installToolTip(javax.swing.JComponent aComponent)
Install the tool tip for this operation on a button or menu item


setAccelerator

public void setAccelerator(javax.swing.KeyStroke keyStroke)
Specify the accelerator key combination for invoking the operation.


setDescription

public void setDescription(java.lang.String operationDescription)
Specify the description of the operation.


setMnemonic

public void setMnemonic(char mnemonic)
Specify the mnemonic character for this action.


GFL 1.1 API