Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Indeterminate JProgressBar While Running Long Task

 
Maas F. Turner
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm new to Java and would like to show a dummy JProgressBar in Indeterminate mode while running a long process. The long process would run in the current thread and the ProgressBar in a new thread.

Could someone please help with some sample code for how to do this?

Thanks.

Example of what I need to do:
 
Darryl Burke
Bartender
Posts: 5126
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maas F. Turner wrote:The long process would run in the current thread and the ProgressBar in a new thread.

If this refers to Swing, you have that back to front. The JProgressBar needs to be addressed and queried on the EDT. A long running task needs to be launched in a background Thread, optiamlly handled by a SwingWorker.

Check out the tutorial linked from the JProgressBar API and another section of the same tutorial titled Concurrency in Swing.

And welcome to the Ranch!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic