This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
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: 11437
    
  87

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: displaying information to the user