• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem with client server chat application

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic