My JProgressBar does not show till the end of its loop condition.
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Pravin_Verma
Posted On:   Thursday, March 22, 2001 01:01 AM

I have a JFrame which consists of a JInternalFrame. I have a condition where I am retrieving a number of records from the database. This process is time consuming and hence till I scroll through the entire recordset I want to show the user its progress through a progress bar. But the progress bar does not show-up until I have scrolled thru the entire recordset and the progress bar shows with its maximum limit!!! Please help me solve this problem!

Re: My JProgressBar does not show till the end of its loop condition.

Posted By:   Scott_Stanchfield  
Posted On:   Wednesday, April 25, 2001 08:13 AM

Go to the Swing FAQ here at jguru.com and search for "invokeLater". Read all of the Q/As that come up.

Hint: You need to do the updating in another thread, as the AWT thread (the one that does the painting) is busy running your loop...

Re: My JProgressBar does not show till the end of its loop condition.

Posted By:   Anonymous  
Posted On:   Thursday, March 22, 2001 03:17 AM

It's hard to say what you do wrong but a will give you general hints for the JProgressBar approach. First, make sure that your thread that update the progressbar runs in the event dispatch thread (AWT thread). You must also make sure that you call the (event dispatch) javax.swing.SwingUtilities.invokeAndWait(myUpdateThread) every time you want to update the progressbar. Thus you may preferably use two threads(main thread is not included) for this approach. One thread that do the real work, recordset processing. Another thread that do the progressbar update. The latter thread must execute on the event dispatch thread.
About | Sitemap | Contact