나는 사용자가 가입해야하며 가입 장면에서 그가의 RadioButton과 성별에 집어 프로그램을 가지고 : 나는 변수 숯불은 "성"이 Screenshot of the program runningJavaFX에서 RadioButton을 누르면 변수를 변경하는 방법은 무엇입니까?
을; RadioButton 사용자가 무엇을 누르는가에 따라 프로그램에서이 문자를 'm'또는 'f'로 변경하기를 원합니다 (남성의 경우 'm', 여성의 경우 'f'). 이것은 내가 지금 가지고있는,하지만 작동하지 않습니다 : 당신의 시간과 노력에 대한
@FXML
private RadioButton male;
@FXML
private RadioButton female;
private char gender;
male.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
gender = 'm';
}
});
female.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
gender = 'f';
}
});
감사합니다!
무엇을 작동하지 않습니다이 그룹의 각 전환에 청취자를 추가하거나 할 수 있는가? 어디에서 작동하지 않습니까? 오류가 있습니까? – Steven
@Steven gender는 눌려진 RadioButton과 관계없이 null로 반환됩니다. –