在处理过程中创建 Modal JDialog

发布于 2024-11-25 20:47:32 字数 51 浏览 6 评论 0原文

如何创建一个模态 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

待天淡蓝洁白时 2024-12-02 20:47:33

为了扩展 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

美煞众生 2024-12-02 20:47:33

如果任务是加载 InputStream,请参阅 ProgressMonitorInputStream

EG(未经测试)

ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(
    parentComponent, message, inputStream);
ProgressMonitor pm = pmis.getProgressMonitor();
pm.setMillisToPopup(millisToPopup);

需要在Thread 中加载InputStream 以避免阻塞EDT。

If the task is to load an InputStream, see ProgressMonitorInputStream.

E.G. (untested)

ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(
    parentComponent, message, inputStream);
ProgressMonitor pm = pmis.getProgressMonitor();
pm.setMillisToPopup(millisToPopup);

It will be necessary to load the InputStream in a Thread in order to avoid blocking the EDT.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文