java mouselistener get coordinates code example
Example 1: java get mouse coordinates
int x = MouseInfo.getPointerInfo().getLocation().x;
int y = MouseInfo.getPointerInfo().getLocation().y;
Example 2: java mouselistener get coordinates
implement MouseListener
@Override
public void mouseClicked(MouseEvent e) {
int x=e.getX();
int y=e.getY();
System.out.println(x+","+y);//these co-ords are relative to the component
}