• Post Reply Bookmark Topic Watch Topic
  • New Topic

Separated GUI (Server/Client)

 
Roldan Baldo
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in package client: i have a class
Client extends Thread
ClientHandler extends Thread
in package GUI: i have all the GUI that I will be using,

I separated the GUI frames because i dont want to mess with the package client classes. Frames is,
ClientGUI extends JFrame
Button btn = new Button("Send Message"); // Just for showing the button


First, i will run the ClientGUI, and created an instance of Client. Connecting in the server is easy because I will make
an instance of Client from package client. Now the problem is when i want to send message to the server is through
the "Send Message" button, but the method i want to call is in the ClientHandler. I can't just declare a new instance of
ClientHandler, because i already did that inside Client Class. How will I access the method inside ClientHandler w/o
creating new instance? Other than setting the method to static.

any suggestion would be much appreciated. thanks.

regards bhadz
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you should use the Client to create the GUI. Or a Connector object which connects the Client and the GUI; both Client and GIU can hold references to the Connector and vice versa.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!