public class Test extends JFrame{
public Test(){
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e){
int x=e.getX()+((Component)e.getSource()).getLocationOnScreen().x;
System.out.println(x);
}
});
}
public static void main(String[] args){
new Test().show();
}
}
//Do the same to y.
//This has been tested all right in my computer.