public interface Action extends ActionListener
Action
interface provides a useful extension to the
ActionListener
interface in cases where the same functionality
may be accessed by several controls.
In addition to the actionPerformed
method defined by the
ActionListener
interface, this interface allows the application to
define, in a single place:
This interface can be added to an existing class or used to create an adapter
(typically, by subclassing AbstractAction
). The Action
object can then be added to multiple Action
-aware containers
and connected to Action
-capable components. The GUI controls can
then be activated or deactivated all at once by invoking the
Action
object's setEnabled
method.
Actions are always bound to a XdevUI
instance.
Components currently supporting Action:
getUI()
,
ActionComponent
,
ActionListener
,
AbstractAction
,
ContextSensitiveAction
Modifier and Type | Field and Description |
---|---|
static String |
CAPTION_PROPERTY
Property name of the caption property.
|
static String |
DESCRIPTION_PROPERTY
Property name of the description property.
|
static String |
ENABLED_PROPERTY
Property name of the enabled property.
|
static String |
ICON_PROPERTY
Property name of the icon property.
|
static String |
SHORTCUT_PROPERTY
Property name of the shortcut property.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a
PropertyChange listener. |
String |
getCaption()
Returns the caption of this action, used e.g.
|
String |
getDescription()
Returns the caption of this action, used e.g.
|
Resource |
getIcon()
Returns the icon of this action.
|
Shortcut |
getShortcut()
Returns the associated shortcut of this action.
|
XdevUI |
getUI()
Returns the UI object which this action is associated with.
|
boolean |
isEnabled()
Returns the enabled state of the
Action . |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a
PropertyChange listener. |
void |
setCaption(String caption)
Sets the caption of this action, used e.g.
|
void |
setDescription(String description)
Sets the description of this action, used e.g.
|
void |
setEnabled(boolean enabled)
Sets the enabled state of the
Action . |
void |
setIcon(Resource icon)
Returns the icon of this action.
|
void |
setShortcut(Shortcut shortcut)
Sets the shortcut for this action.
|
actionPerformed
static final String CAPTION_PROPERTY
setCaption(String)
,
Constant Field Valuesstatic final String ICON_PROPERTY
setIcon(Resource)
,
Constant Field Valuesstatic final String DESCRIPTION_PROPERTY
setDescription(String)
,
Constant Field Valuesstatic final String ENABLED_PROPERTY
setEnabled(boolean)
,
Constant Field Valuesstatic final String SHORTCUT_PROPERTY
setShortcut(Shortcut)
,
Constant Field Valuesvoid addPropertyChangeListener(PropertyChangeListener listener)
PropertyChange
listener. Containers and attached
components use these methods to register interest in this
Action
object. When its enabled state or other property
changes, the registered listeners are informed of the change.listener
- a PropertyChangeListener
objectvoid removePropertyChangeListener(PropertyChangeListener listener)
PropertyChange
listener.listener
- a PropertyChangeListener
objectaddPropertyChangeListener(java.beans.PropertyChangeListener)
XdevUI getUI()
String getCaption()
XdevButton
.void setCaption(String caption)
XdevButton
.
If the value has changed, a PropertyChangeEvent
is sent to
listeners.
caption
- the new captionCAPTION_PROPERTY
Resource getIcon()
void setIcon(Resource icon)
If the value has changed, a PropertyChangeEvent
is sent to
listeners.
icon
- the icon of this actionICON_PROPERTY
String getDescription()
XdevButton
.void setDescription(String description)
XdevButton
.
If the value has changed, a PropertyChangeEvent
is sent to
listeners.
description
- the new captionDESCRIPTION_PROPERTY
Shortcut getShortcut()
void setShortcut(Shortcut shortcut)
ActionListener.actionPerformed(ActionEvent)
method will be triggered, given that this action is enabled.
If the value has changed, a PropertyChangeEvent
is sent to
listeners.
The change of the shortcut will not reflect to already created components.
shortcut
- the new shortcutSHORTCUT_PROPERTY
boolean isEnabled()
Action
. When enabled, any
component associated with this object is active and able to fire this
object's actionPerformed
method.Action
is enabledvoid setEnabled(boolean enabled)
Action
. When enabled, any
component associated with this object is active and able to fire this
object's actionPerformed
method.
If the value has changed, a PropertyChangeEvent
is sent to
listeners.
enabled
- true to enable this Action
, false to disable itENABLED_PROPERTY