How do I update a JProgress Bar inside a thread?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Corwin Moyne
    New Member
    • Feb 2012
    • 37

    How do I update a JProgress Bar inside a thread?

    I have a thread that runs some data. I want the progress bar to update as the thread runs. But how can I get the info from the thread to set the progress bar value?

    What is the correct way to achieve this?
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    A clean way to do this would be using the observer pattern (sometimes called the listener pattern). Simply put, you register the progress bar as a listener which waits for something in the thread to change. When something changes the thread says "hey, I've done something!" and the progress bar reacts to that.

    Comment

    Working...