GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes problem with client server chat application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem with client server chat application" Watch "problem with client server chat application" New topic
Author

problem with client server chat application

Keith Mc C
Greenhorn

Joined: May 01, 2005
Posts: 23
happy new year folks,

i am writing a client server chat application in which i am currently trying to do this :
public class Chat extends JFrame implements Runnable { .....

i'm not sure this is the best way possible but it is mainly because i am copying another example TCPChat.java and i used JFrameBuilder to design the GUI.

so heres the problem :
public static void main(String[] args)
{
Chat chatObj = new Chat();
chatObj.run();
}
(in main i am creating an instance of Chat and calling its run() method from main also -
but then every time there is a change of state in the connectionstatus i need to call the run method again from the below function ..? :
// The non-thread-safe way to change the GUI components while
// changing state
private static void changeStatusNTS(int newConnectStatus, boolean noError) {
// Change state if valid state
if (newConnectStatus != NULL) {
connectionStatus = newConnectStatus;
}

// If there is no error, display the appropriate status message
if (noError) {
statusString = statusMessages[connectionStatus];
}
// Otherwise, display error message
else {
statusString = statusMessages[NULL];
}

// Call the run() routine (Runnable interface) on the
// current thread
chatObj.run();
}

i know i cant say chatObj.run(); from here so what should i do

thanks in advance if ANY1 could please help me out
 
Don't get me started about those stupid light bulbs.
 
subject: problem with client server chat application