Skip to main content


2 replies [Last post]
Joined: 2006-02-17

Anyone successfully implement a JProgessBar into their Swing app? I've tried, but on occassion the updating/painting when I set intermediate false does not happen. I fear messing with threads as such since Swing threading is quite complex. Any ideas or suggestions?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Shane Whitehead
Joined: 2006-02-17

ultimatly, the progress bar's ability to update itself will come down to what else is happening in the current event dispatching thread (EDT).

If you are carrying out a lot of work in the EDT, you will most likely find the UI becoming unresponsive.

Remember, Swing will compress calls to repaint into a single call to prevent it from making multiple calls when the thread becomes avalaible, so making calls to invalidate/repaint, may not always work the way you expect them to.

You best to try and perform some of these lengthy tasks in another thread and use SwingUtlities.invokeLater to make peridoical calls to the EDT on your behave

Joined: 2006-02-17

Hi jarna,

When using Swing, you should not be touching any GUI component from another thread. It sounds like you might be doing so. If you have to update a Swing component from another thread, use SwingUtilities.invokeLater().