Search code examples
javaswingmouseeventdispatchevent

Dispatch MouseEvent


Is there a way to dispatch MouseEvent, same as dispatchKeyEvent using the KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(listener); that happens before the event transferred to the component ?

I know I have 2 options

1) add mouse event to all compoenents recursive

2) use a transparent glasspane

Does Java support this , or do I have to use the one of the options above?

thank you


Solution

  • what i finally did was

    long  eventMask = AWTEvent.MOUSE_MOTION_EVENT_MASK
             + AWTEvent.MOUSE_EVENT_MASK;
    Toolkit.getDefaultToolkit().addAWTEventListener(
             new MouseListener(){....}, eventMask);
    

    thank you alll