[英]JavaFX: Show a Dialog window when a user clicks the X button?
I have a basic JavaFX program and I'm trying to add functionality where if the user clicks the window's X button, a Dialog button appears.我有一个基本的 JavaFX 程序,我正在尝试添加功能,如果用户单击窗口的 X 按钮,则会出现一个对话框按钮。 How would I hook into the X button?
我将如何连接到 X 按钮?
You can set an EventHandler
to the stage's close request:您可以将
EventHandler
设置为舞台的关闭请求:
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent e) {
// SHOW A DIALOG HERE
Platform.exit();
System.exit(0);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.