Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

displaying information to the user

 
Suba Raj
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Suba Raj
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Im stuck with this problem . If any one can give me some insight, it would be great. Please help!!

Thanx,
Suba
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11865
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suba,

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).

Regards, Andrew
 
Suba Raj
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew,
Im sorry abt that. But Im thankful to you, for giving another perspective, to accomplish it. Let me give it a try that way.

Thanx once again,
Suba
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic