0

Hi I am trying to implement a progress bar into my java code. My java code consists of a graphical user interface that runs an executable file via processBuilder, and streamGobbler. When I implement this code for the progress bar:

private void updateProgressBar(final int newValue){

    SwingUtilities.invokeLater(new Runnable() {
        public void run(){
            progressBar.setValue(newValue);
        }
    });

}

But it seems as though that the progress bar does not update while the executable is running in the background. I have also implemented processbuilder for the progress bar and that also has not worked. What should I do in order to have this progress bar to work.

Thank you

mKorbel
  • 109,525
  • 20
  • 134
  • 319
funSizes
  • 57
  • 1
  • 8
  • It sounds like your executing your external process from the EDT, either that or the value you're passing `updateProgressBar` is invalid... – MadProgrammer Mar 29 '14 at 03:24
  • The value is inputted fine as it is a counter variable, so if it is via the EDT how do I go about it? – funSizes Mar 29 '14 at 03:50
  • 2
    You would use a background thread do run your background process, such as one that is provided by a SwingWorker. Google "Concurrency in Swing" and check out the first hit for the important details. – Hovercraft Full Of Eels Mar 29 '14 at 04:02
  • Thank you this ended working. What I needed to do was separate my code files and my calculations to run in the background while the external program finished running. – funSizes Apr 15 '14 at 17:44

0 Answers0