• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Progress Bar

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an executable jar that extracts files from itself. I would like to have a JProgressBar show the progress of this. Below is the code I use for extraction. How can I implement a JProgressBar to use this? I would like to increment it with each "buffered IO dump".

Thanks in advance,
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jason,
Probably the best way to do this is to construct a JProgressBar and a Timer (javax.swing.Timer). Then add an ActionListener to the Timer and in the actionPerformed method update the Progress Bar. You'll probably have to experiment with how often the Timer fires to get the granularity you want. As you probably know you shouldn't modify any swing components outside the event thread, so don't be tempted to just update the Progress bar on the fly.
One other possibility you may check out is the ProgressMonitor class.
Hope this helps
Michael Morris
SCJP2
[ March 25, 2002: Message edited by: Michael Morris ]
 
New rule: no elephants at the chess tournament. Tiny ads are still okay.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic