Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

JProgressBar not resetting to 0 or repainting

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
It is difficult to free fools from the chains they revere - Voltaire. tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic