Hi, Im having some trouble in displaying some informative message to the user in a JLabel. This is what im trying to do: when the client makes a request to connect to the remote server, Im trying to display a message in a JLabel which says "Connecting to server". But before this message could be displayed in the label the successive statements are getting executed and the label is getting updated only after these statements. The interface is not being updated when it has to be. I have spent lot of time trying other alternatives. But couldnt find a solution. So any help is appreciated. I also tried to use a progress bar but the problem seems to be that the interface is updated only at last. Andrew, please help!!!
Thanx in advance. Suba
Joined: Jul 20, 2005
Hi, Im stuck with this problem . If any one can give me some insight, it would be great. Please help!!
It is generally a bad idea to ask a specific person for help - quite often other forum members see that it was addressed to the specific person, so they don't join in. You could be missing replies from other forum members, and at the same time not getting replies from me (because I am really busy at the moment).
I suspect you are doing all your work in the AWT event dispatching thread, and that thread is busy doing the work you are asking for rather than updating the display.
You could create a separate thread to do the work, then update the screen using a Thread invoked via the SwingUtilities (or EventQueue) invokeLater() method.
Be very careful if you go down this path though - it is very easy to give users the wrong impression (they might think the application is ready for the next command when in reality you still need the response from your other thread).