public class GenericAction
extends javax.swing.AbstractAction
The simplest GenericAction. Instances should be added as ActionListeners to "Action" Controls -- Buttons, Menu Items, and Toolbar Buttons only. This class keeps a reference to a Model
Modifier and Type | Field and Description |
---|---|
private java.lang.reflect.Method |
actionMethod |
private java.lang.Object |
model |
Constructor and Description |
---|
GenericAction(java.lang.Object theModel,
java.lang.reflect.Method method) |
GenericAction(java.lang.Object theModel,
java.lang.String methodName)
Construct with given target object and method name.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent event)
When the ActionEvent is heard, invoke the "action" method on the
corresponding object (model).
|
void |
putValue(java.lang.String key,
java.lang.Object value)
This "fixes" AbstractAction so that the enabled property can be treated
like any other.
|
java.lang.String |
toString() |
private java.lang.Object model
private java.lang.reflect.Method actionMethod
public GenericAction(java.lang.Object theModel, java.lang.String methodName)
theModel
- the target objectmethodName
- the name of the method to be invokedpublic GenericAction(java.lang.Object theModel, java.lang.reflect.Method method)
public void actionPerformed(java.awt.event.ActionEvent event)
When the ActionEvent is heard, invoke the "action" method on the corresponding object (model). Note that no information contained in the ActionEvent is actually required.
event
- The ActionEvent that is heard.public void putValue(java.lang.String key, java.lang.Object value)
This "fixes" AbstractAction so that the enabled property can be treated like any other. Note that AbstractAction.setEnabled() fires a PropertyChangeEvent, as does AbstractAction.putValue().
putValue
in interface javax.swing.Action
putValue
in class javax.swing.AbstractAction
key
- The key of the property to be setvalue
- The value of the property.public java.lang.String toString()
toString
in class java.lang.Object