Create Modal JDialog while things are processing

how do you create a Modal JDialog saying “loading” while a task is processing that shows after more than 3 seconds has passed?


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

E.G. (untested)

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

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

Leave a Reply

Your email address will not be published. Required fields are marked *