com.rubecula.darwin.visualization
Class FlipFlopButtons
java.lang.Object
com.rubecula.darwin.visualization.FlipFlopButtons
- All Implemented Interfaces:
- ActionListener, EventListener
public class FlipFlopButtons
- extends Object
- implements ActionListener
Class which manages a set of JButtons (usually of cardinality two),
belonging to a container and, when pressed, invoking
calls to an implementer of ControlAction.
When a button is pressed, two things will happen:
- the ControlAction implementer will be called with
ControlAction.setState(String)
where the parameter is the action command for the button;
- every button's enabled state will be flipped.
- Author:
- Robin
|
Method Summary |
void |
actionPerformed(ActionEvent event)
|
boolean |
addButton(String command,
boolean enabled)
Mutating method to create a new JButton and:
add it to this object's Container
set its enabled state (from the given parameter)
add this as an action listener to it
add it to the list of buttons
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FlipFlopButtons
public FlipFlopButtons(ControlAction controlAction,
Container container)
actionPerformed
public void actionPerformed(ActionEvent event)
- Specified by:
actionPerformed in interface ActionListener
addButton
public boolean addButton(String command,
boolean enabled)
- Mutating method to create a new
JButton and:
- add it to this object's
Container
- set its enabled state (from the given parameter)
- add
this as an action listener to it
- add it to the list of buttons
- Parameters:
command - used to define both the label and the action command for a the new button.enabled - the initial value of the enabled property for the new button.
- Returns:
- the result of calling
Collection.add(Object) on the buttons list with parameter the new button. - See Also:
Collection.add(java.lang.Object)