charvax.swing
Class ButtonGroup

java.lang.Object
  extended bycharvax.swing.ButtonGroup
All Implemented Interfaces:
EventListener, ItemListener

public class ButtonGroup
extends java.lang.Object
implements ItemListener

This class is used to create a multiple-exclusion scope for a set of buttons. Adding a set of buttons to a ButtonGroup object means that turning any one of these buttons "on" turns off all other buttons in the group.

Initially, all buttons in the group are unselected. Once any button in the group is selected, one button is always selected in the group.

Note that the ButtonGroup is a logical grouping, not a physical grouping. To create a button panel, you should still create a JPanel and add the JRadioButtons to it.


Constructor Summary
ButtonGroup()
          Creates a new ButtonGroup
 
Method Summary
 void add(AbstractButton button_)
          Adds the specified button to the group.
 int getButtonCount()
          Returns the number of buttons in the ButtonGroup.
 java.util.Enumeration getElements()
          Returns an Enumeration of all the buttons in this group.
 AbstractButton getSelection()
          Get the selected radiobutton.
 boolean isSelected(AbstractButton button_)
          Returns the selected value for the specified button.
 void itemStateChanged(ItemEvent e_)
          Implements the ItemListener interface.
 void remove(AbstractButton button_)
          Remove the specified button from the group.
 void setSelected(AbstractButton button_, boolean val_)
          Sets the selected value for the specified button.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ButtonGroup

public ButtonGroup()
Creates a new ButtonGroup

Method Detail

add

public void add(AbstractButton button_)
Adds the specified button to the group.


getButtonCount

public int getButtonCount()
Returns the number of buttons in the ButtonGroup.


getElements

public java.util.Enumeration getElements()
Returns an Enumeration of all the buttons in this group.


getSelection

public AbstractButton getSelection()
Get the selected radiobutton. Returns null if no button is selected.


isSelected

public boolean isSelected(AbstractButton button_)
Returns the selected value for the specified button.


remove

public void remove(AbstractButton button_)
Remove the specified button from the group.


setSelected

public void setSelected(AbstractButton button_,
                        boolean val_)
Sets the selected value for the specified button. This method doesn't appear to make sense but it is present in the Swing version of ButtonGroup.


itemStateChanged

public void itemStateChanged(ItemEvent e_)
Implements the ItemListener interface. Listens for state changes from all the buttons in the group.

Specified by:
itemStateChanged in interface ItemListener