how to add a listener to a toggle group radio buttons javafx

Solutions on MaxInterview for how to add a listener to a toggle group radio buttons javafx by the best coders in the world

showing results for - "how to add a listener to a toggle group radio buttons javafx"
Simon
27 Jun 2017
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