How to wait for events to happen without using sleeps.

hi,

I am basically doing Thread.sleep() for waiting the events to complete.

For example, when i click on query button, it takes sometime to process in the background & then populate the data in my table.

So i am using the sleep method for this event to finish.

I feel this is not the correct approach, can anyone suggest just me a way to wait for the event to finish without actually using sleep method.

Thanks & Regards,

Vishal

[480 byte] By [vishal_vja] at [2007-11-27 3:57:48]
# 1

Hi Vishal;

Using sleep() is very bad. my suggestion

a. Run query process in background with ordinary thread.

And

b. use progress bar if you can estimate that how much of background work is completed otherwise use an indefinite progress bar upto finesh query process with Event Dispatch Thread.

Message was edited by:

GsrC

GsrCa at 2007-7-12 9:02:09 > top of Java-index,Desktop,Core GUI APIs...
# 2

Hi,

Firstly thanks for your valuable suggestion. But i would like to mention one thing, actually i am using JFCunit framework for doing Unit Testing for our Swing based client. So here i am not looking into Swing code that is being developed but rather i am concentrating on writing unit tests to whatever that is been developed.

So when i click on the query button automatically, it is taking sometime to process (few seconds) & then its populating the data in a table. So in this case if i have to use the progress bar for the event to finish, i guess i have to modify the source code which is not advisable when you are doing unit testing. So i would appreciate if there is any other alternative that you could suggest me apart from using the progress bar.

Thanks & Regards,

Vishal

vishal_vja at 2007-7-12 9:02:09 > top of Java-index,Desktop,Core GUI APIs...