public class RadioButton extends Component implements TextComponent
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);
Modifier and Type | Field and Description |
---|---|
protected TextState |
textState
Used to represent text state of radio button.
|
Constructor and Description |
---|
RadioButton()
Default constructor.
|
RadioButton(float x,
float y,
float width,
float height)
Constructor with position and size parameters.
|
RadioButton(java.lang.String text)
Default constructor.
|
RadioButton(java.lang.String text,
float x,
float y,
float width,
float height)
Constructor with position and size parameters.
|
RadioButton(java.lang.String text,
org.joml.Vector2f position,
org.joml.Vector2f size)
Constructor with position and size parameters.
|
RadioButton(org.joml.Vector2f position,
org.joml.Vector2f size)
Constructor with position and size parameters.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
Icon |
getIconChecked()
Returns radio image for checked state.
|
Icon |
getIconUnchecked()
Returns radio image for non-checked state.
|
RadioButtonGroup |
getRadioButtonGroup()
Returns current radio button group.
|
TextState |
getTextState()
Returns current text state.
|
int |
hashCode() |
boolean |
isChecked()
Returns true if radio button is checked.
|
void |
setChecked(boolean checked)
Used to set radio button checked or not.
|
void |
setIconChecked(Icon iconChecked)
Used to set radio image for checked state.
|
void |
setIconUnchecked(Icon iconUnchecked)
Used to set radio image for non-checked state.
|
void |
setRadioButtonGroup(RadioButtonGroup radioButtonGroup)
Used to set radio button group.
|
java.lang.String |
toString() |
add, addAll, clearChilds, containerIterator, contains, containsAll, count, forEach, getAbsolutePosition, getBackgroundColor, getBorder, getChilds, getCornerRadius, getFocusedStrokeColor, getIntersector, getListenerMap, getMetadata, getParent, getPosition, getSize, getTooltip, intersects, isEmpty, isEnabled, isFocused, isHovered, isPressed, isVisible, parallelStream, remove, removeAll, removeIf, setBackgroundColor, setBackgroundColor, setBorder, setCornerRadius, setEnabled, setFocused, setFocusedStrokeColor, setFocusedStrokeColor, setHovered, setIntersector, setListenerMap, setParent, setPosition, setPosition, setPressed, setSize, setSize, setTooltip, setVisible, stream
protected TextState textState
public RadioButton()
Also if you want to make it easy to use with Json marshaller/unmarshaller component should contain empty constructor.
public RadioButton(float x, float y, float width, float height)
x
- x position position in parent component.y
- y position position in parent component.width
- width of component.height
- height of component.public RadioButton(org.joml.Vector2f position, org.joml.Vector2f size)
position
- position position in parent component.size
- size of component.public RadioButton(java.lang.String text)
Also if you want to make it easy to use with Json marshaller/unmarshaller component should contain empty constructor.
text
- text to set.public RadioButton(java.lang.String text, float x, float y, float width, float height)
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.public RadioButton(java.lang.String text, org.joml.Vector2f position, org.joml.Vector2f size)
text
- text to set.position
- position position in parent component.size
- size of component.public boolean isChecked()
public void setChecked(boolean checked)
checked
- true if it should be checked.public RadioButtonGroup getRadioButtonGroup()
public void setRadioButtonGroup(RadioButtonGroup radioButtonGroup)
radioButtonGroup
- radio button group to set.public Icon getIconUnchecked()
public void setIconUnchecked(Icon iconUnchecked)
iconUnchecked
- radio image for non-checked state to set.public Icon getIconChecked()
public void setIconChecked(Icon iconChecked)
iconChecked
- radio image for checked state to set.public TextState getTextState()
getTextState
in interface TextComponent