-1

I have 10 Clients connected to my server. I have 10 JButtons in my server UI. The clientsystems and buttons are named as 1,2,3 to 10. Now when I click button1 from my server UI, I need to send a small message to client1. I don't know how to achieve this. Can I assign the IP address of a client to a button and then communicate with the client using this IP?

question
  • 392
  • 1
  • 4
  • 15
  • Clarified the question, removed several typos and correct a few grammatical mistakes. Try to avoid simple mistakes like plural vs. singular in the future. This will help people a lot to understand your question. –  Apr 22 '15 at 13:55

1 Answers1

0

Use ActionListener to acheive the result.

public void actionPerformed(ActionEvent e) {
         String command = e.getActionCommand();
          //use if condition to differentiate your Buttons that you have clicked.

          //other stuff.
}
CoderNeji
  • 2,056
  • 3
  • 20
  • 31
Shriram
  • 4,343
  • 8
  • 37
  • 64