org.jminor.common.ui.control
Class MethodControl

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.jminor.common.ui.control.Control
          extended by 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

Field Summary
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
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
 
Constructor Summary
MethodControl(String name, Object owner, String methodName)
          Instantiates a new MethodControl object
MethodControl(String name, Object owner, String methodName, StateObserver enabledState)
          Instantiates a new MethodControl object
 
Method Summary
 void actionPerformed(ActionEvent e)
          
 void addActionPerformedListener(ActionListener listener)
           
 void removeActionPerformedListener(ActionListener listener)
           
 
Methods inherited from class org.jminor.common.ui.control.Control
getDescription, getEnabledState, getIcon, getMnemonic, getName, isEnabled, setDescription, setEnabled, setIcon, setKeyStroke, setMnemonic, setName
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, putValue, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 required
owner - the object owning the method being called
methodName - 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 required
owner - the object owning the method being called
methodName - the name of the method to call
enabledState - 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
Method Detail

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