JavaFX 2.0:关闭一个阶段(窗口) [英] JavaFX 2.0: Closing a stage (window)

查看:233
本文介绍了JavaFX 2.0:关闭一个阶段(窗口)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在JavaFX 2.0中创建一个应用程序。在我的主窗口中,我正在启动一个带有一些设置的新窗口。调整设置后,我想按下保存更改之类的按钮。

I'm making a application in JavaFX 2.0. From my main window I am starting a new window with some settings. After I am done adjusting the settings I want to press a button like "Save changes".

我希望此按钮保存更改并关闭窗口。
关闭我的意思是杀死它,而不是将它放在后台或设置可见性。
我读过一个方法Stage.close()

I would like this button to save the changes and close the window. By closing i mean killing it, not placing it in the background or setting the visibility. I've read about a method Stage.close()


http://docs.oracle.com/javafx/2.0/api/javafx/stage/Stage.html

正如你所看到的,它类似于方法Hide(),它只隐藏窗口,而不是关闭窗口。

As you can see it's similar to the method Hide(), which only hides the window, not closing it.

问:有人知道任何方法或有一些代码可以帮我关闭窗口吗?

Q: Anybody knows any methods or have some code that would help me close a window?

所有帮助将不胜感激。
谢谢!

All help will be greatly appreciated. Thanks!

推荐答案

您链接的文档说明 stage.close()


关闭此阶段。此调用相当于hide()。

Closes this Stage. This call is equivalent to hide().

As hide()是相当于 close() close()关闭舞台,然后 hide()也会关闭舞台。

As hide() is equivalent to close() and close() closes the stage, then hide() also closes the stage.

当应用程序中的所有阶段都被隐藏(或者如果你愿意,可以关闭,因为它是相同的),申请退出。令人困惑,我知道,但这就是JavaFX团队决定命名和实施行动的方式。

When all stages in an application are hidden (or closed if you like, because it is the same thing), the application exits. Confusing, I know, but that's just the way the JavaFX team decided to name and implement the actions.

如果需要, Platform.setImplicitExit(boolean)方法可用于关闭默认值最后一个窗口关闭或隐藏时退出应用程序的行为。

If desired, the Platform.setImplicitExit(boolean) method can be used to switch off the default behaviour of exiting the application when the last window is closed or hidden.

这篇关于JavaFX 2.0:关闭一个阶段(窗口)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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