|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
By encapsulating a request as an object, commands let you parameterize clients with different requests, queue or log requests, and support undo/redo operations.
The Command interface is one implementation of the well-known
GoF pattern just described. Our Command objects are identified,
described, executable objects with an enabling state that can be controlled
by client code. These characteristics are reflected in the declared methods
of the interface. Commands can be attached to both MenuBar and
ToolBar items and generally facilitate the extension of custom
applications.
All commands have these common characteristics and abilities:
perform(Object) method
The identifier is used to look up the object in the CommandRegistry
and has to be unique. The behavior of a Command is coded in the
perform(Object) method of an implementation class. If a description
has been set and the Command is used in a ToolBar,
this description will be shown as a Tooltip. The perform description describes
what the Command is doing during its execution. This string is
shown in the StatusBar for a short period of time.
{@link http://java.sun.com/products/jfc/swingdoc-api-1.0.3/com/sun/java/swing/Action.html>Action}| Method Summary | |
java.lang.String |
getDescription()
Returns the description of this command. |
java.lang.String |
getId()
Retrieves the unique identifier of the command. |
java.lang.String |
getPerformDescription()
Returns a textual description of what the command does when it is invoked. |
boolean |
isEnabled()
Returns true if this command is enabled. |
void |
perform(java.lang.Object args)
This method will specify the functionality the command offers. |
void |
setEnabled(boolean enabled)
Specifies whether this command is enabled or not. |
| Method Detail |
public void perform(java.lang.Object args)
args - optional parameter for this commandpublic java.lang.String getId()
public java.lang.String getDescription()
null
otherwise.public java.lang.String getPerformDescription()
getDescription() is, that the returned
String of this method describes what the Command does
when it performs.
The String returned by getDescription() describes what the
command will do.
For example:
You specify a command that opens a document.
null if it is not set.public boolean isEnabled()
true if this command is enabled.
true if this command is enabled.public void setEnabled(boolean enabled)
enabled - specifies whether this command is enabled.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||