I an working on JavaFX 8 and SceneBuilder. I created some radio buttons in the FXML File and specified a toggleGroup name to a radio button list in
The solution I got is:
ToggleGroup toggleGroup = new ToggleGroup();
Then set toggleGroup to the radio button; let's say r1 and r2
r1.setToggleGroup(toggleGroup);
r2.setToggleGroup(toggleGroup);
toggleGroup.setUserData(toggleGroup.getSelectedToggle().toString());
To print the data of RadioButton:
System.out.println("Selected Radio Button is " + toggleGroup.getUserData().toString());