Package rma.swing

Class JButtonGroup

All Implemented Interfaces:
Serializable

public class JButtonGroup extends ButtonGroup
Extends javax.swing.ButtonGroup to provide methods that allow working with button references instead of button models.
See Also:
  • Constructor Details

    • JButtonGroup

      public JButtonGroup()
      Creates an empty JButtonGroup
    • JButtonGroup

      public JButtonGroup(AbstractButton[] buttons)
      Creates a JButtonGroup object from an array of buttons and adds the buttons to the group No button will be selected initially.
      Parameters:
      buttons - an array of AbstractButtons
  • Method Details

    • add

      public void add(AbstractButton button)
      Adds a button to the group
      Overrides:
      add in class ButtonGroup
      Parameters:
      button - an AbstractButton reference
    • add

      public void add(AbstractButton[] buttons)
      Adds an array of buttons to the group
      Parameters:
      buttons - an array of AbstractButtons
    • remove

      public void remove(AbstractButton button)
      Removes a button from the group
      Overrides:
      remove in class ButtonGroup
      Parameters:
      button - the button to be removed
    • remove

      public void remove(AbstractButton[] buttons)
      Removes all the buttons in the array from the group
      Parameters:
      buttons - an array of AbstractButtons
    • setSelected

      public void setSelected(AbstractButton button, boolean selected)
      Sets the selected button in the group Only one button in the group can be selected
      Parameters:
      button - an AbstractButton reference
      selected - an boolean representing the selection state of the button
    • setSelected

      public void setSelected(ButtonModel model, boolean selected)
      Sets the selected button model in the group
      Overrides:
      setSelected in class ButtonGroup
      Parameters:
      model - a ButtonModel reference
      selected - an boolean representing the selection state of the button
    • getButton

      public AbstractButton getButton(ButtonModel model)
      Returns the AbstractButton whose ButtonModel is given. If the model does not belong to a button in the group, returns null.
      Parameters:
      model - a ButtonModel that should belong to a button in the group
      Returns:
      an AbstractButton reference whose model is model if the button belongs to the group, nullotherwise
    • getSelected

      public AbstractButton getSelected()
      Returns the selected button in the group.
      Returns:
      a reference to the currently selected button in the group or null if no button is selected
    • isSelected

      public boolean isSelected(AbstractButton button)
      Returns whether the button is selected
      Parameters:
      button - an AbstractButton reference
      Returns:
      true if the button is selected, false otherwise
    • getButtons

      public List getButtons()
      Returns the buttons in the group as a List
      Returns:
      a List containing the buttons in the group, in the order they were added to the group
    • contains

      public boolean contains(AbstractButton button)
      Checks whether the group contains the given button
      Returns:
      true if the button is contained in the group, false otherwise