作者gozha (勾炸)
看板java
标题[问题] MouseListener 跟 MouseMotionListener
时间Sun May 17 21:39:58 2009
public class XXX implements MouseListener, MouseMotionListener{
private int strtX, strtY;
public XXX(){
strtX = strtY = 0;
}
public void mousePressed(MouseEvent e){
strtX = e.getX();
strtY = e.getY();
System.out.println(strtX + " " + strtY);
}
public void mouseReleased(MouseEvent e){
System.out.println(strtX + " " + strtY);
}
public void mouseDragged(MouseEvent e){
System.out.println(strtX + " " + strtY);
}
}
这是我的程式码片段
执行过程中,印出的顺序跟我想的一样
mousePressed → mouseDragged → mouseReleased
但是印出结果跟不一样= =
mousePressed 跟 mouseReleased 的印出一致的结果
表示从 pressed到 released 的过程中 strtX 跟 strtY 并没有被更动
但是 mouseDragged 总是印出 0 0
这是为什麽呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.122.184.62