• 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

Separated GUI (Server/Client)

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79240
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic