<Swing Dev> Bug 6306075

Pavel Porvatov pavel.porvatov at oracle.com
Wed Jun 13 15:08:56 UTC 2012

Hi Paulo,
> A old simple bug that probably causes a lot of pain:
> ProgressMonitor.setMaximum only works during construction, not while 
> the component is in operation.
> The bizarre workaround (in a periodic eventqueue runnable)
>             int current = getProgress();
>             JComponent root = (JComponent) 
> view.getContentPane().getComponent(0);
>             GroupLayout l = (GroupLayout) root.getLayout();
>             JProgressBar old = view.progressBar;
>             view.progressBar = new JProgressBar(current, size);
>             l.replace(old, view.progressBar);
>             view.repaint();
> Actually ProgressMonitor is a strange component, because it is almost 
> broken by design. It uses it's methods outside of the EDT (i know this 
> from a swing detection library), and requires the code that initiates 
> construction to start it from outside the EDT (the actual 
> construction, being in the EDT) - this is because since setVisible is 
> blocking for dialogs, the thing that is being measured can't be on the 
> same thread. Also, there is yet another thread involved in the 
> creation, due to some tasks requiring a lot of time to get the extent 
> or give up; like in a url.
> Could you fix these problems? (the last 2 are not 'problems' per-se, 
> just warts).
The described bug 
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6306075 is fixed. Is 
the problem reproducible on some jdk?

Regards, Pavel

More information about the swing-dev mailing list