wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes displaying information to the user Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "displaying information to the user" Watch "displaying information to the user" New topic
Author

displaying information to the user

Suba Raj
Greenhorn

Joined: Jul 20, 2005
Posts: 13
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

Joined: Jul 20, 2005
Posts: 13
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

Joined: Mar 28, 2003
Posts: 11404
    
  81

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


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Suba Raj
Greenhorn

Joined: Jul 20, 2005
Posts: 13
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: displaying information to the user
 
Similar Threads
problem with struts1.1 please help me...
Problem in displaying message using resource bundle for validation framework
GUI- Beginner............ myWindow.getContentPane().add(myLabel)?? explain please
EJB help, very confused with gui's and JFrames with J2EE
Using swing as a client for an EJB, help