1ToggleGroup genderGroup = new ToggleGroup();
2male.setToggleGroup(genderGroup);
3female.setToggleGroup(genderGroup);
4genderGroup.selectedToggleProperty().addListener(
5 (observable, oldToggle, newToggle) -> {
6 if (newToggle == male) {
7 gender = 'm';
8 } else if (newToggle == female) {
9 gender = 'f';
10 } else {
11 gender = '?';
12 }
13 }
14);
15