cara menambahkan pendengar ke tombol radio grup sakelar javafx

ToggleGroup genderGroup = new ToggleGroup();
male.setToggleGroup(genderGroup);
female.setToggleGroup(genderGroup);
genderGroup.selectedToggleProperty().addListener(
   (observable, oldToggle, newToggle) -> {
       if (newToggle == male) {
           gender = 'm';
       } else if (newToggle == female) {
           gender = 'f';
       } else {
           gender = '?';
       }
    }
);
Funny Ferret