• 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

Indeterminate JProgressBar While Running Long Task

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic