views:

30

answers:

1

Hello,

I want to know the state of my mouse buttons (pressed or not), from outside the target component.

I don't want to use a glasspane to intercept events.

The MouseInfo class can give me the location of the mouse, but not its state.

Is there a way of retrieving mouse state from anywhere in the application ?

Thanks.

+1  A: 

The mouse state only changes when a MouseEvent is generated, so you need to listen for MouseEvents.

I guess you could add a global MouseListener to track the state yourself based on the last MouseEvent generated. Check out the Global Event Listeners for an example of using the AWTEventListener.

camickr