需要从简单的 java 应用程序中读取鼠标按钮状态(“按下”或“释放”)。可能吗?
谢谢!
您可以使用MouseListener接口,或者它是有用的抽象实现MouseAdapter:
public class MyMouseListener extends MouseAdapter {
private boolean pressed = false;
public void mousePressed(MouseEvent e) {
this.pressed = true;
}
public void mouseReleased(MouseEvent e) {
this.pressed = false;
}
public boolean isPressed() {
return pressed;
}
}
MouseEvent是您正在寻找的类