java mouselistener get coordinates

Solutions on MaxInterview for java mouselistener get coordinates by the best coders in the world

showing results for - "java mouselistener get coordinates"
Aitana
09 Feb 2016
1int x =  MouseInfo.getPointerInfo().getLocation().x;
2int y = MouseInfo.getPointerInfo().getLocation().y;
Jesús
10 Sep 2019
1implement MouseListener
2
3@Override
4public void mouseClicked(MouseEvent e) {
5    int x=e.getX();
6    int y=e.getY();
7    System.out.println(x+","+y);//these co-ords are relative to the component
8}