Jprogressbar not updating

Posted by / 07-May-2019 17:41

Jprogressbar not updating

All you need to do is adapt the second example i posted to your case and all the threading will be taken care of But would not the updating of the progress bar be in this different thread as well because it's inside the loop?the problem is that the loop is *not* inside the different thread you need to move it into the run() method of the thread so it is run in the different thread I am in class the next 2 days I will try these suggestions Friday when I am back at work.The Thread class is an inner class as follows: class Progress Thread extends Thread The JProgress Bar is on Process Dialog.I create the Progress Dialog and attempt to increment it's Progress Bar as follows in my main class: Progress Thread pt = new Progress Thread(); //Creates and displays the Progress Bar Dialog pt.start(); for (int i = 0; i You need to do updates to gui components on the event dispatch thread.The progress bar appeared but did not update correctly (like before) during the loop.Of course as before that same code worked fine in a little stand-allone application I created. I basically wrapped a thread around the loop using Thread t = new Thread(....Amyway I have another problem now because the main thread that creates this side or spawned thread moves ahead and attempts to use objects that are being processed by the side thread so exceptions get thrown.I guess I somehow need the main thread to wait until the spawned thread has completed until it attempts to process the objects the spawned thread is working on.

Objects I tried that code using Progress Handle in Netbeans 6.9 (newest version) I need to include the Progress API I think, but I am not sure if it's in Netbeans 6.9. I then instantiated the class and called that method from our application.

Event Dispatch Thread (EDT) is responsible for many tasks related to swing components.

If you use a long loop inside the Event Dispatch thread, it will become busy and unable to bring about necessary changes in the swing components.

CEHJ I guess you mean the Swing Worker code that uses the Property Change Listener on the progress bar?

I actually tried that the other day and maybe I coded it incorrectly but it did not work. Actually that code looks similiar to the code I have now except that the Swing Worker replaces the Thread and you add a Property Change Listerer to the progress bar.

jprogressbar not updating-23jprogressbar not updating-78jprogressbar not updating-46

It shows up only when whole of the processis completed.

One thought on “jprogressbar not updating”