import javax.swing.*; import java.awt.event.*; import java.net.*; import java.io.*; public class Client2 extends JPanel implements MouseListener{ Socket sc; PrintWriter pw; BufferedReader br; public Client2(){ addMouseListener(this); try{ sc=new Socket("192.168.2.231", 3001); pw=new PrintWriter(sc.getOutputStream(), true); pw.println("Jaagup"); } catch(Exception ex){ex.printStackTrace();} } public void mousePressed(MouseEvent e){ System.out.println(e.getX()+" "+e.getY()); pw.println(e.getX()+" "+e.getY()); } public void mouseReleased(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public static void main(String[] args){ JFrame f=new JFrame("Client"); f.getContentPane().add(new Client2()); f.setSize(400, 300); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }