com.rubecula.darwin.visualization.swing
Class FlipFlopButtons

java.lang.Object
  extended by com.rubecula.darwin.visualization.swing.FlipFlopButtons
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class FlipFlopButtons
extends java.lang.Object
implements java.awt.event.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:

  1. the ControlAction implementer will be called with ControlAction.setState(String) where the parameter is the action command for the button;
  2. every button's enabled state will be flipped.

Author:
Robin Hillyard

Constructor Summary
FlipFlopButtons(ControlAction controlAction, java.awt.Container container)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
           
 boolean addButton(java.lang.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
 

Constructor Detail

FlipFlopButtons

public FlipFlopButtons(ControlAction controlAction,
                       java.awt.Container container)
Parameters:
controlAction -
container -
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Specified by:
actionPerformed in interface java.awt.event.ActionListener
See Also:
ActionListener.actionPerformed(java.awt.event.ActionEvent)

addButton

public boolean addButton(java.lang.String command,
                         boolean enabled)
Mutating method to create a new JButton and:
  1. add it to this object's Container
  2. set its enabled state (from the given parameter)
  3. add this as an action listener to it
  4. 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)


Copyright © 2010 Rubecula Software, LLC. All Rights Reserved.