Answers for "how to add a listener to a toggle group radio buttons javafx"

0

how to add a listener to a toggle group radio buttons 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 = '?';
       }
    }
);
Posted by: Guest on January-12-2021

Code answers related to "how to add a listener to a toggle group radio buttons javafx"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language