• Post Reply Bookmark Topic Watch Topic
  • New Topic

JProgressBar not resetting to 0 or repainting  RSS feed

 
Shaun Seah
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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%?

tks!
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!