我创建了一个带有额外FXML文件和一些标签的PopUp。现在我想设置标签,当PopUp显示时,这不起作用。
@FXML
private void handleButtonAction(ActionEvent event) throws
IOException, InterruptedException {
Stage stage;
Parent root;
if(event.getSource()==button) {
stage = new Stage();
root = FXMLLoader.load(getClass().getResource("popup.fxml"));
stage.setScene(new Scene(root));
stage.setTitle("New PopUp");
stage.initModality(Modality.APPLICATION_MODAL);
stage.initOwner(button.getScene().getWindow());
label1.setText("test");
stage.showAndWait();
}
else {
stage=(Stage)back.getScene().getWindow();
stage.close();
}
}
您是否有任何提示正确设置label1? THX