This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes PROBLEM in displaying message in chat window 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 "PROBLEM in displaying message in chat window" Watch "PROBLEM in displaying message in chat window" New topic
Author

PROBLEM in displaying message in chat window

ahmedali mohd
Greenhorn

Joined: Apr 14, 2010
Posts: 15
Hi All

Here is my problem. My application is chat application which normally it is doing correctly between client and server with SWING components seperately. Client and Server having two seperate windows which are working fine when they seperately chat to each other.
Now problem creating when i m embedded this application into JFrame window. I m using Main window(JFrame by keep layout as null) like yahoo chat. Client and Server layouts are different it means they are using GridLayout and panel. I added one dynamic button in Main window which performs an action to open Server program. Server program having a run method where ServerSocket initialise are present.

Button having code like this using actionlistener or mouselistener for label

Server2 myobj=new Server2(); //This line is fine
myobj.myServer(); // But problem from this line ...

When i m clicking on that dynamic button. My server socket chat window becomes blur means nothing it is display on the screen except only Title bar even though every component set properly and running fine while doing seperately with the client.

When Client is sending the data to Server. Connection established properly and getting the result in the background flow of Server program but not in the text area of Server chat window.

When i m terminating the client application. What ever the messages client window had sent to server window i can see it ...
So, I need you people to help me how to overcome this problem , it is very urgent please help me out from this situation.

Server window should highlight all its button once i click to button. Why it is totally becoming white in color( without displaying nothing ). When Client windows terminates, then only it is showing ... So why and give me code where i need to make a change

When i m invoking this method, it is hiding everything. Is't the problem with the layout betwen two windows ( main & Server window) or . Any flow is wrong ? ...Please let me know


Code for Server -


public void myServer()
{
//for receive connections
try {
server=new ServerSocket(12345,100);
while( true )
{
try {
System.out.println("yes");
System.out.println(" Before waiting connection");
mywaitConnection();
System.out.println(" After connecting to client and before stream data");
getMyStreamData();
System.out.println(" After stream data but before process connections");
processMyConnection();

}
catch(EOFException ef)
{ System.err.println("error"+ef); }
finally { closeConnection(); ++counter;
} //step 5 connection close

} //end of while
} // end of outer try
catch( IOException ioe ) { ioe.printStackTrace(); }

}









Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Please UseCodeTags. You can use the edit button to add them to your post.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: PROBLEM in displaying message in chat window
 
Similar Threads
peer to peer
Server Socket window hanging while calling from JFrame window
SERVER socket ---- SERVER socket
Related to ServerSocket
force close server socket while waits for connection