我試圖讓鼠標的位置,同時按下鼠標按鈕,但它不工作。 我延伸的MouseAdapter
及於的Javadoc陳述的mouseMove()
被調用時鼠標光標已被移動到組件上但沒有按鈕被按壓。捕捉鼠標運動,同時按下鼠標懸停在Java中
這是我創建了給你看我的問題的例子類:
public class TestMouse extends MouseAdapter{
int x,y;
boolean pressed;
public void mousePressed(MouseEvent e){
pressed = true;
}
public void mouseReleased(MouseEvent e){
pressed = false;
}
/*
Invoked when the mouse is not pressed only.
*/
public void mouseMoved(MouseEvent e){
x = e.getX();
y = e.getY();
}
/*
I want something like that.
*/
public void mousePressedAndMoved(MouseEvent e){
....
}
}
您是否嘗試過的mouseDragged()? – arcy