Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: How to display the "Application is Connecting" message in Network mode?

 
amchi gelo
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My question is for when you bring up the Network Configuration Client which asks the Host and Port to connect to. I put these values in and hit "Launch". Lets say that I put in some junk values which are valid, but the host/port do not exist and an RMI connection cannot be made.
What happens now is the the "Launch" button gets "dis-enabled" and the client GUI looks like its hung for around 10 seconds, then the popup opens up which says that the host/port cannot be found. I would like for something like "Application is connecting.... please wait" to be displayed in the status bar before it starts looking to make the connection so that the user doesn't think that the application has hung on him It seems to me that the GUI is not updating the status bar with the new label in time before which it starts to make the connection.
I tried doing an updateUI, even put a delay wait loop so that the gui could refresh itself, but it just doesn't work.
What do I do? Has anyone else encountered this situation?
Thanks,
Sanjay
[ February 15, 2004: Message edited by: Sanjay Joshi ]
 
Raj Shekhar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sanjay,
Did you try setting the status label text before you attempt to get the connection? for e.g.

I do not have a status bar for configuration screen but my Main gui has a status bar and it seemed to be working.
HTH
Raj
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sanjay,
Originally posted by Sanjay Joshi:
It seems to me that the GUI is not updating the status bar with the new label in time before which it starts to make the connection.
I tried doing an updateUI, even put a delay wait loop so that the gui could refresh itself, but it just doesn't work.
What do I do? Has anyone else encountered this situation?

Been there, done that. You're trying to do non-trivial work (it's taking about 10 seconds to make the connection) using the Swing event-handling thread. Take a look at this thread topic: Topic: JFrame not repainting when overlayed JDialog is closed . I think you're going to want to spawn a new thread (other than the Swing event-handling thread) that will make the connection. This will allow the Swing event-handling thread to refresh the GUI as you're expecting. If after looking at the referenced topic you still have questions, let me know.
Hope this helps,
George
[ February 15, 2004: Message edited by: George Marinkovich ]
 
amchi gelo
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raj, yes, I tried that, it didn't work.
George, thanks for your reply yet again! I'll look at the thread you quote and see if that works.
Sanjay
 
amchi gelo
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
George, I tried a threads solution and I get the desired result.
The way I have done it is I spawn one thread to get the remote connection and another thread to contain an infinite loop to check the errorcode I generate in the first thread depending on whether the connection is successful or throws an exception. When it gets this from the first thread, the second thread breaks out of the loop and calls the code to run the main GUI which contains the JTable etc...
Any better solutions? I tried to think up one with just 1 thread, but I couldn't arrive at one which runs outside the Swing thread and achieves all that I want to.
Sanjay
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic