This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Progress Bar refreshing! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Progress Bar refreshing!" Watch "Progress Bar refreshing!" New topic

Progress Bar refreshing!

Jenith shiva

Joined: Oct 16, 2001
Posts: 3
I have a JProgressBar on my status pane.
As I progress I need to set the value on the Progress Bar so I call this method...
public void setValue(int value){
SwingUtilities.invokeLater(new Runnable(){
public void run(){
This should repaint the ProgressBar with the value as the rest of the task is in progress, but it does not refresh itself until the whole task is complete.

Please help me out in doing the needfull to refresh the ProgressBar as and when the setValue() method is called.

Thanks n Regards
Wilfried LAURENT
Ranch Hand

Joined: Jul 13, 2001
Posts: 269
You should have posted this message in the Swing/awt forum. Bartender, can you do that?
The updateUI method code is useless here. It is used to change properties of the look-and-feel, which is here not the case. So you can remove it.
Swing uses a modified Model-View-Controller (MVC pattern), which a Model-UI pattern. When a call to setValue() in JProgressBar is made, this call is delegated to the model which is embedded in the JProgressBar. The model then notifies the view that it should repaint. This should be automatic. So I don't quite get the point using invokeLater.

[This message has been edited by Wilfried LAURENT (edited October 17, 2001).]
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
sure, I will move this to Swing.

"JavaRanch, where the deer and the Certified play" - David O'Meara
raj madhuram
Ranch Hand

Joined: Oct 10, 2001
Posts: 71
This might help:
I agree. Here's the link:
subject: Progress Bar refreshing!
It's not a secret anymore!