在JavaFX上,如何在不处理它并关闭应用程序的情况下隐藏舞台? [英] On JavaFX, how to hide stage without disposing it and closing the application?

查看:126
本文介绍了在JavaFX上,如何在不处理它并关闭应用程序的情况下隐藏舞台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个向用户显示主要阶段的应用程序,如果用户关闭了该阶段,而不是完成应用程序,则应该隐藏该阶段以供以后使用。
在摆动时,我们可以将setVisible(false)调用到JFrame或JDialog,但是如何在JavaFX上执行?

I need to creat an app that shows the primary stage to the user, and if the user closes the stage, instead of finishing the application, it should just hide the stage for later use. On swing we could just call setVisible(false) to a JFrame or JDialog, but how to do it on JavaFX?

推荐答案

一旦JavaFX工具包启动,默认情况下它将在最后一个可见窗口关闭时关闭。

Once the JavaFX toolkit has started, by default it will close down when the last visible window is closed.

为了防止这种情况,你可以调用

To prevent this, you can call

Platform.setImplicitExit(false);

您通常在 start(...)方法,虽然它可以从任何线程调用。

You typically do this in your start(...) method, though it can be called from any thread.

要退出应用程序,您需要调用

To exit the application, you would then need to call

Platform.exit();

(因为申请不再自动退出)。

(as the application no longer exits automatically).

这篇关于在JavaFX上,如何在不处理它并关闭应用程序的情况下隐藏舞台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆