【发布时间】:2023-04-04 06:38:01
【问题描述】:
我需要通过控制器中的代码关闭当前的fxml窗口
我知道 stage.close() 或 stage.hide() 在 fx 中这样做
如何在 fxml 中实现这一点?我试过了
private void on_btnClose_clicked(ActionEvent actionEvent) {
Parent root = FXMLLoader.load(getClass().getResource("currentWindow.fxml"));
Scene scene = new Scene(root);
Stage stage = new Stage();
stage.setScene(scene);
stage.show();
}
但它不起作用!
我们将不胜感激所有帮助。谢谢!
【问题讨论】:
标签: java user-interface javafx fxml