I need to save the selection status of multiple RadioButtons, so I can see which RadioButton is selected, when I go back to the scene later on. It's not about the userData, it's about to see whether it's selected. Right now I know how to make it work but with a lot of messy copy & paste. Something like this for every ToggleGroup:
@FXML private RadioButton rb1;
@FXML private RadioButton rb2;
public static int[] status = new int[600];
// to save it
if (rb1.getSelect(true)){
status[0] = 1;
} else {
status[0] = 0;
}
// to load it
if (status[0] == 1){
rb1.setSelected(true);
} else {
rb2.setSelected(true);
}
The problem is that I program a survey with more than 300 questions with binary answers. So I have more than 600 different RadioButtons. It'd take hours to implement it this way.
Is there any smart way to do it? I'm grateful for any advice. Thanks in advance!
