• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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 ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic