在处理过程中创建 Modal JDialog
如何创建一个模态 JDialog,在处理任务时显示“正在加载”,并在超过 3 秒后显示?
how do you create a Modal JDialog saying "loading" while a task is processing that shows after more than 3 seconds has passed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了扩展 Paul 的答案,SwingWorker 可以很好地运行您的后台任务。然后,您可以显示进度或进度监视器,教程可以在此处为您提供帮助: 如何使用进度条
To expand on Paul's answer, a SwingWorker would work well for running your background task. You could then display either a progress or a progress monitor, and the tutorials can help you here: How to Use Progress Bars
如果任务是加载
InputStream
,请参阅ProgressMonitorInputStream
。EG(未经测试)
需要在
Thread
中加载InputStream
以避免阻塞EDT。If the task is to load an
InputStream
, seeProgressMonitorInputStream
.E.G. (untested)
It will be necessary to load the
InputStream
in aThread
in order to avoid blocking the EDT.