1

I wrote a simple chat server with GUI and a simple chat client with GUI. I can open the server in one computer and the client in another computer within the local network. the client user type the address of the server host computer and start chatting. I also wrote a Tic Tac Toe game with GUI.

Now I want to embed the game into the server-client program. I have no idea how/where to start. (the embedding itself is not the problem, the problem is how to make it work through a network)

The Tic tac toe game is simply in a JPanel contained in a JFrame, the JPanel is set to GridLayout(3, 3), and 9 JButtons added to the JPanel. I wrote all the necessary coding to make the game work.

So the basic Question is how to make swing events transfer between client and server

  • When user 'A 'chooses "games -> Tic Tac Toe" a request send to user 'B' about "start gaming" and launch the game frame.

And the crucial part:

  • When user 'A' clicks on a JButton (in the game), the corresponding event sent to user 'B' so that both GUI ends are identical. ('A' and 'B' see the same GUI changes).

How to start? What are the required things? Any hints?

Thank you

Saleh Feek
  • 2,048
  • 8
  • 34
  • 56

1 Answers1

1

I believe, you have defined an interface over which your server/client interactions are done. Define a method using which you can send & receive the messages. Your JButton clicks just have to identify which Tile is clicked/moved and give that information over interface to server/client. Passing the Swing events are not good idea.

R Kaja Mohideen
  • 909
  • 1
  • 8
  • 24