ch.aplu.jgamegrid
Class GGRadioButtonGroup

java.lang.Object
  extended by ch.aplu.jgamegrid.GGRadioButtonGroup

public class GGRadioButtonGroup
extends java.lang.Object

A radio button group contains a certain number of radio buttons. The group takes care of unselecting the previously selected button when the user selects another button in the group. Initially, if all buttons added to the group are deselected, no button is selected. When a selected button is added to the group, any previously selected button is deselected. A button should not be contained in more than one button group.


Constructor Summary
GGRadioButtonGroup()
          Creates a GGRadioButtonGroup instance that contains no button.
GGRadioButtonGroup(GGRadioButton... radioButtons)
          Creates a GGRadionButton instance that contains the given GGRadioButtons.
 
Method Summary
 void add(GGRadioButton... radioButtons)
          Adds the given GGRadioButtons to the group.
 void add(GGRadioButton radioButton)
          Adds the given GGRadioButton to the group.
 void addRadioButtonListener(GGRadioButtonListener listener)
          Registers the given GGRadioButtonListener to get notifications when the currently selected button changes because the user clicks another button.
 java.util.ArrayList<GGRadioButton> getButtons()
          Returns a list of all buttons added to the group.
 GGRadioButton getSelectedButton()
          Returns the currently selected button.
 int getSelectedButtonId()
          Returns the id of the currently selected button.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GGRadioButtonGroup

public GGRadioButtonGroup()
Creates a GGRadioButtonGroup instance that contains no button.


GGRadioButtonGroup

public GGRadioButtonGroup(GGRadioButton... radioButtons)
Creates a GGRadionButton instance that contains the given GGRadioButtons. If more than one button is already selected, all but the last are deselected.

Parameters:
radioButtons - the GGRadioButtons to be added to the group
Method Detail

add

public void add(GGRadioButton... radioButtons)
Adds the given GGRadioButtons to the group. If more than one button is selected, all but the last are deselected.

Parameters:
radioButtons - the GGRadioButtons to be added to the group

add

public void add(GGRadioButton radioButton)
Adds the given GGRadioButton to the group. If the button is already selected, any previously selected button is deselected.

Parameters:
radioButton - the GGRadioButton to be added to the group

getSelectedButton

public GGRadioButton getSelectedButton()
Returns the currently selected button.

Returns:
the currently selected button, null if no button is selected

getSelectedButtonId

public int getSelectedButtonId()
Returns the id of the currently selected button. The button ids corresponds to the order the buttons are added to the button group.

Returns:
the id of the selected button, -1 if no button is selected

getButtons

public java.util.ArrayList<GGRadioButton> getButtons()
Returns a list of all buttons added to the group.

Returns:
all GGRadioButtons in the group

addRadioButtonListener

public void addRadioButtonListener(GGRadioButtonListener listener)
Registers the given GGRadioButtonListener to get notifications when the currently selected button changes because the user clicks another button.

Parameters:
listener - the GGRadioButtonListener to register