org.jminor.common.ui.control
Class MethodControl
java.lang.Object
javax.swing.AbstractAction
org.jminor.common.ui.control.Control
org.jminor.common.ui.control.MethodControl
- All Implemented Interfaces:
- ActionListener, Serializable, Cloneable, EventListener, Action
public final class MethodControl
- extends Control
A Control class for binding an action to a parameterless method via reflection.
- See Also:
- Serialized Form
Fields inherited from interface javax.swing.Action |
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON |
Methods inherited from class org.jminor.common.ui.control.Control |
getDescription, getEnabledState, getIcon, getMnemonic, getName, isEnabled, setDescription, setEnabled, setIcon, setKeyStroke, setMnemonic, setName |
MethodControl
public MethodControl(String name,
Object owner,
String methodName)
- Instantiates a new MethodControl object
- Parameters:
name
- the name of this control, used when a caption is requiredowner
- the object owning the method being calledmethodName
- the name of the method to call
- Throws:
RuntimeException
- if the method was not found in the owner object
MethodControl
public MethodControl(String name,
Object owner,
String methodName,
StateObserver enabledState)
- Instantiates a new MethodControl object
- Parameters:
name
- the name of this control, used when a caption is requiredowner
- the object owning the method being calledmethodName
- the name of the method to callenabledState
- if specified then this control will only be enabled when this state is
- Throws:
RuntimeException
- if the method was not found in the owner object
actionPerformed
public void actionPerformed(ActionEvent e)
-
- Specified by:
actionPerformed
in interface ActionListener
- Overrides:
actionPerformed
in class Control
addActionPerformedListener
public void addActionPerformedListener(ActionListener listener)
- Parameters:
listener
- a listener notified each time action performed is called
removeActionPerformedListener
public void removeActionPerformedListener(ActionListener listener)
- Parameters:
listener
- the listener to remove