charvax.swing
Class ButtonGroup
java.lang.Object
charvax.swing.ButtonGroup
- EventListener, ItemListener
public class ButtonGroup
extends java.lang.Object
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.
ButtonGroup
public ButtonGroup()
Creates a new ButtonGroup
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 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.
itemStateChanged
public void itemStateChanged(ItemEvent e_)
Implements the ItemListener interface. Listens for state
changes from all the buttons in the group.
- itemStateChanged in interface ItemListener
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.