简体   繁体   中英

Can you find who placed a call on the EDT from the AWTEvent object?

There are some calls on the Event Dispatch Thread that I would like to know from where the call originated. I have a new class that extends and hooks into the EventQueue .

This allows me to override the dispatchEvent() routine and work with the AWTEvent object.

protected void dispatchEvent(AWTEvent event) 
{
    try 
    {
        preDispatchEvent();
        super.dispatchEvent(event);
    } 
    finally 
    {
        postDispatchEvent();
    }
}

Using the AWTEvent.paramString() routine, it prints the following which isn't very helpful:

    java.awt.event.InvocationEvent[INVOCATION_DEFAULT,runnable=sun.awt.GlobalCursorManager$NativeUpdater@1c926eac,notifier=null,catchExceptions=false,when=1563800245516] on sun.awt.windows.WToolkit@4020b9cf

Based on the AWTEvent object, is it possible to find which call placed the Event on the EDT?

The AWTEvent method getSource() will tell you the object that caused the event to be dispatched. I'm not sure it is possible to tell exactly which call caused the event.

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