File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JProgressBar not resetting to 0 or repainting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JProgressBar not resetting to 0 or repainting" Watch "JProgressBar not resetting to 0 or repainting" New topic

JProgressBar not resetting to 0 or repainting

Shaun Seah

Joined: Mar 15, 2011
Posts: 3
Hi guys,

I have a JSwing frame that queries a database and spits out results in a JTable.
I have included a JProgressBar to monitor as each record is retrieved after a button is pressed.

So far the code works when i click on my button the first time, however subsequent button clicks the JProgressBar does not reset to 0.

heres some code:

Can anyone shed a light why the second time i click on retrive button the progressBar doest not reset to 0 and stays at 100%?

Darryl Burke

Joined: May 03, 2008
Posts: 5091

Because you're scheduling the long running task on the EDT instead of in a background Thread.

Go through the tutorial on Concurrency in Swing linked from the tutorial on How to Use Progress Bars, which again is linked from the API for JProgressBar.

luck, db
There are no new questions, but there may be new answers.
I agree. Here's the link:
subject: JProgressBar not resetting to 0 or repainting
It's not a secret anymore!