wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes strange problem with swing based windows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "strange problem with swing based windows" Watch "strange problem with swing based windows" New topic
Author

strange problem with swing based windows

Raghav Mathur
Ranch Hand

Joined: Jan 12, 2001
Posts: 641
Hi
I 've developed a chat client which is a swing based interface . There is a login .Once the user clicks on login after feeding the account info , the client communicates with the server and after the server sends and "OK" , the client login screen hides and a chat window( comprising of 2 text areas) opens up. Now there are 2 things which are happening .
1) Sometimes that window(which opens up after login) doesn't move nor can i type anything in the windows textarea but i can recieve messages from the other clients in that window
2) Second thing is when a different window overlaps the client chat window and is then minimised , the client chat window becomes totally disabled. It becomes brown in color , that means it doesn't even show the components
( textarea) added to it.
Any clue of what is going on ??
Thanks a ton in advance


Raghav.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

The problem is that you are blocking the event thread somewhere. All event handling and screen repaints are done in the event thread, so if it gets blocked for some reason your application is basically locked up like you've seen. Code that runs in the event thread includes code in event handler methods (like actionPerformed() in actionListener) or code in the run() method of Runnables invoked through SwingUtilities.invokeLater() or invokeAndWait(). Things that can cause blocks are obvious Thread related ones like sleep() and wait(), along with methods that block on IO, like file reads and writes and socket reads and writes. Making a remote call is using socket IO, so I'm betting that the event thread is getting blocked making a call to your server that is getting called from the 'login' button's action listener. A way to fix this would be for the button's action listener to only start a thread that would make the call to the server for you. Then that separate thread would get blocked while the call is made, but the event thread is free to handle other events and repaints as soon as it exits your actionPerformed() after starting the thread.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Raghav Mathur
Ranch Hand

Joined: Jan 12, 2001
Posts: 641
If this might be the prob then let me also tell you that it does not get blocked always . Most of the times it works fine .

Actually i am starting a thread as soon as i am flushing some string and the thread( a class implements runnable) which i am starting also provokes the chat window and also inturn start 2 threads , one for reading input and one for writing output .

Also , my chat window does open . It also reads messages but i am not able to write .
What to do ?
[ November 01, 2003: Message edited by: raghav mathur ]
Raghav Mathur
Ranch Hand

Joined: Jan 12, 2001
Posts: 641
Ok Nathan
Do you mean to say that i should start the Thread which also pops up the chat window, seperatly and not when i click on the login button ?
Is that your point ?
If yes then i can do one thing. I can use flags . I mean to say when the user has looged in and the chat thread is to be started , i won't start it as soon as somebody clicks on login , but i shall set a flag , a boolean value so that when the Thread event for the button is over and the authentication with the server is sucessfull , the falg shall be set to "true" and after checking the flag value i shall start the thread( which pops up the chat window)
What say you ?
Thanks a ton in advance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: strange problem with swing based windows
 
Similar Threads
Problem in JFrame
Browser does not support swing
PROBLEM in displaying message in chat window
Issue in session manegement
Server Socket for chat