aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Progress Bar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Progress Bar" Watch "Progress Bar" New topic
Author

Progress Bar

Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
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,


Jason R. Kretzer<br />Software Engineer<br />System Administrator<br /><a href="http://alia.iwarp.com" target="_blank" rel="nofollow">http://alia.iwarp.com</a>
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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 ]

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
Consider Paul's rocket mass heater.
 
subject: Progress Bar