Class RadioButton

All Implemented Interfaces:
TextComponent, Serializable

public class RadioButton extends AbstractTextComponent
RadioButtons create a series of items where only one item can be checked.

By default all created radio buttons have no group so all of them can be checked.

Usage example:


 RadioButtonGroup rbg = new RadioButtonGroup();
 RadioButton      rb1 = new RadioButton();
 RadioButton      rb2 = new RadioButton();
 radioButton1.setRadioButtonGroup(radioButtonGroup);
 radioButton2.setRadioButtonGroup(radioButtonGroup);
 
See Also:
  • Field Details

    • DEFAULT_RADIO_BUTTON_TEXT

      public static final String DEFAULT_RADIO_BUTTON_TEXT
      Default text for radiobutton.
      See Also:
  • Constructor Details

    • RadioButton

      public RadioButton()
      Default constructor. Used to create component instance without any parameters.

      Also if you want to make it easy to use with Json marshaller/unmarshaller component should contain empty constructor.

    • RadioButton

      public RadioButton(float x, float y, float width, float height)
      Constructor with position and size parameters.
      Parameters:
      x - x position position in parent component.
      y - y position position in parent component.
      width - width of component.
      height - height of component.
    • RadioButton

      public RadioButton(org.joml.Vector2f position, org.joml.Vector2f size)
      Constructor with position and size parameters.
      Parameters:
      position - position position in parent component.
      size - size of component.
    • RadioButton

      public RadioButton(String text)
      Default constructor. Used to create component instance without any parameters.

      Also if you want to make it easy to use with Json marshaller/unmarshaller component should contain empty constructor.

      Parameters:
      text - text to set.
    • RadioButton

      public RadioButton(String text, float x, float y, float width, float height)
      Constructor with position and size parameters.
      Parameters:
      text - text to set.
      x - x position position in parent component.
      y - y position position in parent component.
      width - width of component.
      height - height of component.
    • RadioButton

      public RadioButton(String text, org.joml.Vector2f position, org.joml.Vector2f size)
      Constructor with position and size parameters.
      Parameters:
      text - text to set.
      position - position position in parent component.
      size - size of component.
  • Method Details

    • isChecked

      public boolean isChecked()
      Returns true if radio button is checked.
      Returns:
      true if radio button is checked.
    • setChecked

      public void setChecked(boolean checked)
      Used to set radio button checked or not.
      Parameters:
      checked - true if it should be checked.
    • getRadioButtonGroup

      public RadioButtonGroup getRadioButtonGroup()
      Returns current radio button group.
      Returns:
      current radio button group.
    • setRadioButtonGroup

      public void setRadioButtonGroup(RadioButtonGroup radioButtonGroup)
      Used to set radio button group.
      Parameters:
      radioButtonGroup - radio button group to set.
    • getIconUnchecked

      public Icon getIconUnchecked()
      Returns radio image for non-checked state.
      Returns:
      radio image for non-checked state.
    • setIconUnchecked

      public void setIconUnchecked(Icon iconUnchecked)
      Used to set radio image for non-checked state.
      Parameters:
      iconUnchecked - radio image for non-checked state to set.
    • getIconChecked

      public Icon getIconChecked()
      Returns radio image for checked state.
      Returns:
      radio image for checked state.
    • setIconChecked

      public void setIconChecked(Icon iconChecked)
      Used to set radio image for checked state.
      Parameters:
      iconChecked - radio image for checked state to set.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Component
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Component
    • toString

      public String toString()
      Overrides:
      toString in class Component