简体   繁体   English

Java中的ModalDialog阻塞

[英]ModalDialog blocking in java

I have a long task which is running and I am popping up a modaldialog with MainUI.modalDialog.setVisible(true); 我有一个很长的任务正在运行,并且正在用MainUI.modalDialog.setVisible(true);弹出MainUI.modalDialog.setVisible(true); which has a ProgressBar. 有一个ProgressBar。 However I do observe that it is blocking the process. 但是,我确实注意到它正在阻止该过程。 How do I popup the Dialog without blocking whatever is running in my frame? 如何在不阻止框架中正在运行的任何内容的情况下弹出对话框?

That is the modal dialogs behavior. 那就是模态对话框的行为。 The options are that you either don't display it as modal or you display it in a separate thread. 选项是您要么不将其显示为模式,要么将其显示在单独的线程中。

You should whatever is running in your frame into another Thread, in case it is not GUI code. 如果不是GUI代码,则应将框架中正在运行的任何内容都放入另一个线程中。 Also you could run the modal dialog in a separate GUI thread. 您也可以在单独的GUI线程中运行模式对话框。

http://en.wikipedia.org/wiki/Modal_window http://en.wikipedia.org/wiki/Modal_window

"In user interface design, a modal window is a child window that requires users to interact with it before they can return to operating the parent application, thus preventing the workflow on the application main window. Modal windows are often called heavy windows or modal dialogs because the window is often used to display a dialog box." “在用户界面设计中,模式窗口是子窗口, 要求用户与其交互才能返回操作父应用程序, 从而阻止了应用程序主窗口上的工作流 。模式窗口通常称为沉重窗口或模式对话框。因为该窗口通常用于显示对话框。”

Solution: Do not use a Modal Window. 解决方案:请勿使用模态窗口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM