com.darwinsys.swingui
Class ButtonExclusionGroup

java.lang.Object
  extended by com.darwinsys.swingui.ButtonExclusionGroup

public class ButtonExclusionGroup
extends java.lang.Object

This class is used to create a single-enablement scope for a set of buttons. It is "Exclusion" in the sense that creating a set of buttons with the same ButtonExclusionGroup object means that sending setEnabled(true) to one of the buttons will send setEnabled(false) to all other buttons in the group.

A ButtonExclusionGroup can be used with objects that inherit from AbstractButton. Typically a button group contains instances of JButton or JMenuItem, but other types could be used. Similar to a Swing "ButtonGroup" but for Enabledness rather than for Selection; only one of the buttons can be enabled at a time. Example:

 JButton goButton = new JButton("Start");
 JButton stopButton = new JButton("Cancel");
 ButtonExclusionGroup group - new ButtonExclusionGroup();
 group.add(goButton);
 group.add(stopButton);
 
Because "two buttons" is the most common form of exclusion, as shown in this example, there is a convenience Constructor; the last three lines could be replaced with
ButtonExclusionGroup group - new ButtonExclusionGroup(goButton, stopButton);


Constructor Summary
ButtonExclusionGroup()
          Construct a ButtonExclusionGroup.
ButtonExclusionGroup(javax.swing.AbstractButton b1, javax.swing.AbstractButton b2)
          Construct a ButtonExclusionGroup with two buttons
 
Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ButtonExclusionGroup

public ButtonExclusionGroup()
Construct a ButtonExclusionGroup.


ButtonExclusionGroup

public ButtonExclusionGroup(javax.swing.AbstractButton b1,
                            javax.swing.AbstractButton b2)
Construct a ButtonExclusionGroup with two buttons

Parameters:
b1 -
b2 -


Copyright © 1996-2004 Ian F. Darwin. See license.html for usage license.