RadioButtons create a series of items where only one item can be
selected. RadioButtons are a specialized ToggleButton
.
When a RadioButton is pressed and released a javafx.event.ActionEvent
is sent. Your application can perform some action based
on this event by implementing an javafx.event.EventHandler
to
process the javafx.event.ActionEvent
.
Only one RadioButton can be selected when placed in a ToggleGroup
.
Clicking on a selected RadioButton will have no effect. A RadioButton that is not
in a ToggleGroup can be selected and unselected. By default a RadioButton is
not in a ToggleGroup. Calling ToggleGroup.getSelectedToggle()
will return you the RadioButton that has been selected.
ToggleGroup group = new ToggleGroup();
RadioButton button1 = new RadioButton("select first");
button1.setToggleGroup(group);
button1.setSelected(true);
RadioButton button2 = new RadioButton("select second");
button2.setToggleGroup(group);
extends