问题描述
我正在尝试使用JavaFX 2创建一个登录窗口并停止执行,直到用户没有登录。我想要如下所示:
I'm trying to create a login window with JavaFX 2 and stop execution until the user has not logged. I want something like the below:
showLoginDialog();
showMainWindow();
showLoginDialog
负责创建一个新阶段并将其父级设置为主窗口。它将阶段设置为模态,我尝试了 WINDOW_MODAL
和 APPLICATION_MODAL
,但是一旦显示登录窗口,也会调用 showMainWindow()
行。
showLoginDialog
is responsible for creating a new stage and set its parent to be the main window. It sets the stage to be modal, I tried both WINDOW_MODAL
and APPLICATION_MODAL
, but as soon as the login window is showed, the showMainWindow()
line is called as well.
是否可以停止代码运行直到<$调用登录阶段的c $ c> close(),或类似的东西?是否有任何教程展示如何实现这一目标?
Is it possible to stop code running until the close()
of the login stage is called, or something similar? Are there any tutorials showing how this can be achieved?
推荐答案
正如Uluk所说,有一个JIRA问题。该问题已在JavaFX的2.2版测试版中关闭并修复。
如果需要停止执行程序,只需使用以下代码:
As Uluk said there is a JIRA issue. The issue has been closed and fixed in version 2.2 beta of JavaFX.Just use the following code if execution of the program needs to be stopped:
modalWindowStage.showAndWait();
其中 modalWindowStage
是用于展示的阶段消息框。
如果执行需要继续,只需使用通常的'show()'方法。
where modalWindowStage
is the stage used for showing the messagebox.If the execution needs to continue, just use the usual 'show()' method.
这篇关于JavaFX 2模态窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!