import javax.swing.*; import java.awt.event.*; public class Client1 extends JPanel implements MouseListener{ public Client1(){ addMouseListener(this); } public void mousePressed(MouseEvent e){ System.out.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 Client1()); f.setSize(400, 300); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }