/*
* @(#)Action.java 1.36 06/04/18
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package javax.swing;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
/**
* The <code>Action</code> interface provides a useful extension to the
* <code>ActionListener</code>
* interface in cases where the same functionality may be accessed by
* several controls.
* <p>
* In addition to the <code>actionPerformed</code> method defined by the
* <code>ActionListener</code> interface, this interface allows the
* application to define, in a single place:
* <ul>
* <li>One or more text strings that describe the function. These strings
* can be used, for example, to display the flyover text for a button
* or to set the text in a menu item.
* <li>One or more icons that depict the function. These icons can be used
* for the images in a menu control, or for composite entries in a more
* sophisticated user interface.
* <li>The enabled/disabled state of the functionality. Instead of having
* to separately disable the menu item and the toolbar button, the
* application can disable the function that implements this interface.
* All components which are registered as listeners for the state change
* then know to disable event generation for that item and to modify the
* display accordingly.
* </ul>
* <p>
* This interface can be added to an existing class or used to create an
* adapter (typically, by subclassing <code>AbstractAction</code>).
* The <code>Action</code> object
* can then be added to multiple <code>Action</code>-aware containers
* and connected to <code>Action</code>-capable
* components. The GUI controls can then be activated or
* deactivated all at once by invoking the <code>Action</code> object's
* <code>setEnabled</code> method.
* <p>
* Note that <code>Action</code> implementations tend to be more expensive
* in terms of storage than a typical <code>ActionListener</code>,
* which does not offer the benefits of centralized control of
* functionality and broadcast of property changes. For this reason,
* you should take care to only use <code>Action</code>s where their benefits
* are desired, and use simple <code>ActionListener</code>s elsewhere.
* <p>
*
* <h4><a name="buttonActions"></a>Swing Components Supporting <code>Action</code></h4>
* <p>
* Many of Swing's components have an <code>Action</code> property. When
* an <code>Action</code> is set on a component, the following things
* happen:
* <ul>
* <li>The <code>Action</code> is added as an <code>ActionListener</code> to
* the component.
* <li>The component configures some of its properties to match the
* <code>Action</code>.
* <li>The component installs a <code>PropertyChangeListener</code> on the
* <code>Action</code> so that the component can change its properties
* to reflect changes in the <code>Action</code>'s properties.
* </ul>
* <p>
* The following table describes the properties used by
* <code>Swing</code> components that support <code>Actions</code>.
* In the table, <em>button</em> refers to any
* <code>AbstractButton</code> subclass, which includes not only
* <code>JButton</code> but also classes such as
* <code>JMenuItem</code>. Unless otherwise stated, a
* <code>null</code> property value in an <code>Action</code> (or a
* <code>Action</code> that is <code>null</code>) results in the
* button's corresponding property being set to <code>null</code>.
* <p>
* <table border="1" cellpadding="1" cellspacing="0"
* summary="Supported Action properties"
* valign="top" >
* <tr valign="top" align="left">
* <th bgcolor="#CCCCFF" align="left">Component Property
* <th bgcolor="#CCCCFF" align="left">Components
* <th bgcolor="#CCCCFF" align="left">Action Key
* <th bgcolor="#CCCCFF" align="left">Notes
* <tr valign="top" align="left">
* <td><b><code>enabled</code></b>
* <td>All
* <td>The <code>isEnabled</code> method
* <td>
* <tr valign="top" align="left">
* <td><b><code>toolTipText</code></b>
* <td>All
* <td><code>SHORT_DESCRIPTION</code>
* <td>
* <tr valign="top" align="left">
* <td><b><code>actionCommand</code></b>
* <td>All
* <td><code>ACTION_COMMAND_KEY</code>
=1= |