Java swing: how to know the state of the mouse from outside the component receiving the event? -


I want to know the position of my mouse button (press or not), from outside the target component.

I do not want to use a glasspin to block incidents.

The MouseInfo Class can give me the location of the mouse, but its position is not.

How to recover mouse position from anywhere in an application?

Thank you.

The mouse position changes only when mouse events are generated, so you need to listen to mouse events.

I think you can add a global mousestist to track yourself based on the last mouse generated event. See for an example using AWTEventListener.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -