nextapp.echo
Class ButtonGroup

java.lang.Object
  extended by nextapp.echo.ButtonGroup
All Implemented Interfaces:
java.io.Serializable

public class ButtonGroup
extends java.lang.Object
implements java.io.Serializable

A container of radio buttons which allows at most one radio button to be selected.

See Also:
Serialized Form

Constructor Summary
ButtonGroup()
          Creates a new ButtonGroup.
 
Method Summary
 void add(AbstractButton button)
          Adds the button to the group.
 int getButtonCount()
          Returns the number of buttons in the group.
 java.util.Iterator getElements()
          Returns all the buttons that are participating in this group.
 ButtonModel getSelection()
          Returns the selected button model.
 boolean isSelected(ButtonModel buttonModel)
          Returns the selected value for the button.
 void remove(AbstractButton button)
          Removes the button from the group.
 void setSelected(ButtonModel buttonModel, boolean selected)
          Sets the selected value for the 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 button to the group. If the button is selected and is added to a group that already has a button that is selected, the button will be automatically deselected.

Parameters:
button - The button to add to the group.

getButtonCount

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

Returns:
The number of buttons in the group.

getElements

public java.util.Iterator getElements()
Returns all the buttons that are participating in this group.

Returns:
An iterator of buttons in this group.

getSelection

public ButtonModel getSelection()
Returns the selected button model.

Returns:
The selected button model.

isSelected

public boolean isSelected(ButtonModel buttonModel)
Returns the selected value for the button.

Parameters:
buttonModel - The button on which to test selection.
Returns:
True if the specified button is selected.

remove

public void remove(AbstractButton button)
Removes the button from the group.

Parameters:
button - The button to remove from the group.

setSelected

public void setSelected(ButtonModel buttonModel,
                        boolean selected)
Sets the selected value for the button.

Parameters:
buttonModel - The button whose state is to be changed.
selected - The new state for the button.