gpt4 book ai didi

java - 当用户选择关闭按钮时如何阻止阶段关闭?

转载 作者:行者123 更新时间:2023-12-02 12:58:51 25 4
gpt4 key购买 nike

我可以添加以下代码来 Hook 阶段关闭事件:

stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
public void handle(WindowEvent we) {
System.out.println("Stage is closing");
// but wait! I don't want it to close!
}
});

但是如何阻止舞台关闭呢?

最佳答案

我指的是this评论:

Platform.setImplicitExit(false);

primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
event.consume();
}
});

关于java - 当用户选择关闭按钮时如何阻止阶段关闭?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44353820/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com