我需要通过控制器中的代码关闭当前的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)
但它不起作用!
所有帮助将不胜感激.谢谢!
查看此代码,它们显示了一种在登录后显示新窗口的方法.当用户名和密码正确时,它会打开新对话框.我想要一个按钮单击打开新对话框,而不检查用户名和密码.