Search code examples
javamultithreadingswingswingworkerjprogressbar

updating TWO JProgressBars


So, I got this working with ONE JProgressBar. How do I update two individual progress bars? I'm executing a download in the doInBackground() worker thread/swingworker method. I want to update two bars, the first is a total, the second is a section of the total. For example, 21/100 //total 21/50 /halvsies

I already asked a question here and finally got this threading thing figured out. I'm now looking to up the ante so to speak and get two progressbars going. Thanks for reading, ~Kyte


Solution

  • You could go the bare-metal route:

    Whenever you want it to be updated:

    EventQueue.invokeLater(new Runnable(){
        public void run(){
            firstProgressBar.setValue(someInt);
            secondProgressBar.setValue(someOtherInt);
        }
    });