开发者

Create Modal JDialog while things are processing

开发者 https://www.devze.com 2023-03-23 02:39 出处:网络
how do you create 开发者_JS百科a Modal JDialog saying \"loading\" while a task is processing that shows after more than 3 seconds has passed?To expand on Paul\'s answer, a SwingWorker would work well

how do you create 开发者_JS百科a Modal JDialog saying "loading" while a task is processing that shows after more than 3 seconds has passed?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消