MouseEvent ex = e.getX() + ((Component)e.getSource()).getLocationScreen().x; 大概就是这么一个意思
多谢:shine333(shine) 能否用一个例子来说明
import java.awt.event.*; import javax.swing.*;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.
大概就是这么一个意思
能否用一个例子来说明
import javax.swing.*;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.
但还是要谢谢shine333(shine) 兄:)
addMouseListener(....);