Java swing: how to detect when the mouse is at rest

I wrote code that has jpanel with a mouse listener and a mouse movement listener, and it works fine, but I run some animations when the mouse is not moving. how can this be detected? Is there a way to smooth some mouse events for a fixed mouse?

+3
source share
1 answer

You may find that the mouse is not moving due to the fact that you are not receiving motion events :-). Just use it.

You can, for example, set a reset timer each time a motion event is triggered. If the timer expires without a motion event (for example, after 1 s), you can start the animation before the motion event appears.

, , . , , , ( , , ).

+4

Source: https://habr.com/ru/post/1772725/


All Articles