简体   繁体   中英

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. You probably want to enable and reset the timer on MouseEnter and disable the timer on 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM