Forums Register Login

How to get hold of the EventDispatchThread

+Pie Number of slices to send: Send
Hi,

I have created a UI class (a JPanel).I have a ComboBox in this UI that shows the Name of all the available objects. When creating a new object from this Panel, it sends a message to SERVER and creats the object in DataBase. The Server replies to the above request with either SUCCESS or FAIL.
If the reply is SUCCESS then I have to update the ComboBox with the name of the new Object.

Problem: The message that I am sending to Server internally creates a timertask and sends message to server. The UI is getting updated before the response is coming back from SERVER. I have to make the EventDispatchThread to wait till it gets response from the server. How do I do this?
[ February 23, 2008: Message edited by: Karthick Dharani Vidhya ]
+Pie Number of slices to send: Send
 

I have to make the EventDispatchThread to wait till it gets response from the server. How do I do this?



You don't. Having the event dispatching thread wait (for anything) is basically having the GUI wait. You don't want to cause the GUI to freeze.

To solve it, you have to remove the part of the code that updates the combo box. Place this code into a runnable object. And then, in your timer task, when you get the response from the server, instantiate and register this runnable object to be executed by the event dispatching thread. (See the SwingUtilites class for info on how to do this)

Henry
[ February 23, 2008: Message edited by: Henry Wong ]
Can you smell this for me? I think this tiny ad smells like blueberry pie!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 779 times.
Similar Threads
How to get hold of the EventDispatchThread
Freezing the UI thread
what is happening, iam unable to see
Sending XML files using HTTP Request/Response?
cookie explanation
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 05:33:32.