我需要通过控制器中的代码关闭当前的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();
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用!
所有帮助将不胜感激.谢谢!