|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.AbstractAction
edu.neu.ccs.gui.SimpleThreadedAction
SimpleThreadedAction is an abstract class that is a simple
extension of the Java AbstractAction class. It is used to
simplify the programming interface for an object representing a GUI
action that requires no parameters and that must be performed in
a new separate thread each time the action is executed.
In a manner parallel to SimpleAction,
to implement a SimpleThreadedAction,
one must extend the abstract
class and define the following method with no parameters:
public void perform()
The SimpleThreadedAction class has a predefined method
public void performThreaded()
that will execute the perform() in a separate thread each time
that it is invoked. The action of the class is performed by calling the
method performThreaded() rather than the method perform().
In particular, if a button is constructed from a SimpleThreadedAction,
its behavior will automatically run in a separate threaded.
For convenience, this class also implements
ChangeListener and
PropertyChangeListener
This class is inspired by the class ThreadedAction
but is programmed directly without use of that class.
| Nested Class Summary |
| Nested classes inherited from class javax.swing.AbstractAction |
|
| Field Summary |
| Fields inherited from class javax.swing.AbstractAction |
changeSupport, enabled |
| Fields inherited from interface javax.swing.Action |
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON |
| Constructor Summary | |
SimpleThreadedAction()
Constructs a simple threaded action with no name or icon. |
|
SimpleThreadedAction(String name)
Constructs a simple threaded action with the given name but no icon. |
|
SimpleThreadedAction(String name,
Icon icon)
Constructs a simple threaded action with the given name and icon. |
|
| Method Summary | |
void |
actionPerformed(ActionEvent evt)
Performs this action by calling the method
which executes the simplified
method
in a separate thread |
abstract void |
perform()
Performs the tasks encapsulated by this action. |
void |
performThreaded()
Executes the method
in a separate thread. |
void |
propertyChange(PropertyChangeEvent evt)
Performs this property change action by calling the method
which executes the simplified
method
in a separate thread |
void |
stateChanged(ChangeEvent evt)
Performs this state change action by calling the method
which executes the simplified
method
in a separate thread |
| 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 |
| Constructor Detail |
public SimpleThreadedAction()
public SimpleThreadedAction(String name)
name - the name for this action
public SimpleThreadedAction(String name,
Icon icon)
name - the name for this actionicon - the icon for this action| Method Detail |
public final void actionPerformed(ActionEvent evt)
performThreaded method
which executes the simplified
perform method
in a separate thread
actionPerformed in interface ActionListenerevt - an object encapsulating an event that triggered this action
this parameter is ignoredpublic final void stateChanged(ChangeEvent evt)
performThreaded method
which executes the simplified
perform method
in a separate thread
stateChanged in interface ChangeListenerevt - an object encapsulating an event that triggered this action
this parameter is ignoredpublic final void propertyChange(PropertyChangeEvent evt)
performThreaded method
which executes the simplified
perform method
in a separate thread
propertyChange in interface PropertyChangeListenerevt - an object encapsulating an event that triggered this action
this parameter is ignoredpublic abstract void perform()
Performs the tasks encapsulated by this action.
Subclasses should override this method to provide tasks this action performs.
If this method is called directly, the tasks will be executed in the
same thread. To cause the tasks to be performed in a separate thread,
call the method .performThreaded
public final void performThreaded()
Executes the method
in a separate thread.perform
To utilize this action algorithmically, this method should be called
rather than the method.perform
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||