[英]Swing: Is there a way to detect if the mouse is still?
在MouseInputAdapter下,有一个mousePressed,mouseReleased,mouseDragged和mouseMoved的侦听器,但是当鼠标静止时是否有一个侦听器?
There is no such event built in. 没有内置此类事件。
If you need that functionality, you may want to consider using a timer. 如果需要该功能,则可能需要考虑使用计时器。 Set the timer to the length of time you want the mouse to be idle before the event is fired.
将计时器设置为您希望鼠标在事件触发之前处于空闲状态的时间长度。 Be sure to reset the timer in the MouseMoved event.
确保在MouseMoved事件中重置计时器。 You probably want to enable and reset the timer on MouseEnter and disable the timer on MouseLeave.
您可能要在MouseEnter上启用和重置计时器,并在MouseLeave上禁用计时器。
No, there's no such listener ie method. 不,没有这样的监听器,即方法。 It's just that, when none of these events is triggered you may assume the mouse is still.
只是,当这些事件均未触发时,您可能会认为鼠标静止不动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.