如何使主界面线程“等待”,直到一个独立的弹出窗口消失 [英] How to make the main GUI thread 'wait' until a separate pop-up window is disappeared

查看:192
本文介绍了如何使主界面线程“等待”,直到一个独立的弹出窗口消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有从主GUI线程调用并显示了若干秒的单独的JFrame然后消失(与使用的计时器)的对象。现在,我想使主界面线程等到弹出的JFrame窗口消失。例如,在主界面code:

I have an object which is invoked from the main GUI thread and shows a separate JFrame for a number of seconds and then disappear (with the use of a timer). Now I want to make the main GUI thread to wait until the pop-up JFrame window disappears. For example, on the main GUI code:

// initiate the object and show the pop-up JFrame
DisappearingJFrame djf = new DisappearingJFrame ();
djf.show ();

// now the main GUI thread should wait
// and after the pop-up JFrame disappears, the rest of the code is then executed
...
...

任何建议将受到欢迎。谢谢你。

Any suggestion would be welcome. Thanks.

推荐答案

不要使用一个单独的JFrame这是模态对话框建成的。使用一个或JOptionPane的一个模式的JDialog。

Don't use a separate JFrame for this is what modal dialogs were built for. Use either a JOptionPane or a modal JDialog.

这篇关于如何使主界面线程“等待”,直到一个独立的弹出窗口消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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