Java Code Examples for sun.awt.EventQueueDelegate#getDelegate()

The following examples show how to use sun.awt.EventQueueDelegate#getDelegate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventDispatchThread.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = true;
            synchronized (eventFilters) {
                for (int i = eventFilters.size() - 1; i >= 0; i--) {
                    EventFilter f = eventFilters.get(i);
                    EventFilter.FilterAction accept = f.acceptEvent(event);
                    if (accept == EventFilter.FilterAction.REJECT) {
                        eventOK = false;
                        break;
                    } else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) {
                        break;
                    }
                }
            }
            eventOK = eventOK && SunDragSourceContextPeer.checkEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}
 
Example 2
Source File: EventDispatchThread.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = filterAndCheckEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}
 
Example 3
Source File: EventDispatchThread.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = filterAndCheckEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}
 
Example 4
Source File: EventDispatchThread.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = true;
            synchronized (eventFilters) {
                for (int i = eventFilters.size() - 1; i >= 0; i--) {
                    EventFilter f = eventFilters.get(i);
                    EventFilter.FilterAction accept = f.acceptEvent(event);
                    if (accept == EventFilter.FilterAction.REJECT) {
                        eventOK = false;
                        break;
                    } else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) {
                        break;
                    }
                }
            }
            eventOK = eventOK && SunDragSourceContextPeer.checkEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}
 
Example 5
Source File: EventDispatchThread.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = filterAndCheckEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}
 
Example 6
Source File: EventDispatchThread.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = filterAndCheckEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}
 
Example 7
Source File: EventDispatchThread.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = filterAndCheckEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}
 
Example 8
Source File: EventDispatchThread.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = true;
            synchronized (eventFilters) {
                for (int i = eventFilters.size() - 1; i >= 0; i--) {
                    EventFilter f = eventFilters.get(i);
                    EventFilter.FilterAction accept = f.acceptEvent(event);
                    if (accept == EventFilter.FilterAction.REJECT) {
                        eventOK = false;
                        break;
                    } else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) {
                        break;
                    }
                }
            }
            eventOK = eventOK && SunDragSourceContextPeer.checkEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}
 
Example 9
Source File: EventDispatchThread.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = true;
            synchronized (eventFilters) {
                for (int i = eventFilters.size() - 1; i >= 0; i--) {
                    EventFilter f = eventFilters.get(i);
                    EventFilter.FilterAction accept = f.acceptEvent(event);
                    if (accept == EventFilter.FilterAction.REJECT) {
                        eventOK = false;
                        break;
                    } else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) {
                        break;
                    }
                }
            }
            eventOK = eventOK && SunDragSourceContextPeer.checkEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}
 
Example 10
Source File: EventDispatchThread.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = true;
            synchronized (eventFilters) {
                for (int i = eventFilters.size() - 1; i >= 0; i--) {
                    EventFilter f = eventFilters.get(i);
                    EventFilter.FilterAction accept = f.acceptEvent(event);
                    if (accept == EventFilter.FilterAction.REJECT) {
                        eventOK = false;
                        break;
                    } else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) {
                        break;
                    }
                }
            }
            eventOK = eventOK && SunDragSourceContextPeer.checkEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}
 
Example 11
Source File: EventDispatchThread.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = true;
            synchronized (eventFilters) {
                for (int i = eventFilters.size() - 1; i >= 0; i--) {
                    EventFilter f = eventFilters.get(i);
                    EventFilter.FilterAction accept = f.acceptEvent(event);
                    if (accept == EventFilter.FilterAction.REJECT) {
                        eventOK = false;
                        break;
                    } else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) {
                        break;
                    }
                }
            }
            eventOK = eventOK && SunDragSourceContextPeer.checkEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}
 
Example 12
Source File: EventDispatchThread.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = true;
            synchronized (eventFilters) {
                for (int i = eventFilters.size() - 1; i >= 0; i--) {
                    EventFilter f = eventFilters.get(i);
                    EventFilter.FilterAction accept = f.acceptEvent(event);
                    if (accept == EventFilter.FilterAction.REJECT) {
                        eventOK = false;
                        break;
                    } else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) {
                        break;
                    }
                }
            }
            eventOK = eventOK && SunDragSourceContextPeer.checkEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}
 
Example 13
Source File: EventDispatchThread.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = filterAndCheckEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}
 
Example 14
Source File: EventDispatchThread.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = true;
            synchronized (eventFilters) {
                for (int i = eventFilters.size() - 1; i >= 0; i--) {
                    EventFilter f = eventFilters.get(i);
                    EventFilter.FilterAction accept = f.acceptEvent(event);
                    if (accept == EventFilter.FilterAction.REJECT) {
                        eventOK = false;
                        break;
                    } else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) {
                        break;
                    }
                }
            }
            eventOK = eventOK && SunDragSourceContextPeer.checkEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}
 
Example 15
Source File: EventDispatchThread.java    From jdk-1.7-annotated with Apache License 2.0 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = true;
            synchronized (eventFilters) {
                for (int i = eventFilters.size() - 1; i >= 0; i--) {
                    EventFilter f = eventFilters.get(i);
                    EventFilter.FilterAction accept = f.acceptEvent(event);
                    if (accept == EventFilter.FilterAction.REJECT) {
                        eventOK = false;
                        break;
                    } else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) {
                        break;
                    }
                }
            }
            eventOK = eventOK && SunDragSourceContextPeer.checkEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}
 
Example 16
Source File: EventDispatchThread.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
void pumpOneEventForFilters(int id) {
    AWTEvent event = null;
    boolean eventOK = false;
    try {
        EventQueue eq = null;
        EventQueueDelegate.Delegate delegate = null;
        do {
            // EventQueue may change during the dispatching
            eq = getEventQueue();
            delegate = EventQueueDelegate.getDelegate();

            if (delegate != null && id == ANY_EVENT) {
                event = delegate.getNextEvent(eq);
            } else {
                event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
            }

            eventOK = true;
            synchronized (eventFilters) {
                for (int i = eventFilters.size() - 1; i >= 0; i--) {
                    EventFilter f = eventFilters.get(i);
                    EventFilter.FilterAction accept = f.acceptEvent(event);
                    if (accept == EventFilter.FilterAction.REJECT) {
                        eventOK = false;
                        break;
                    } else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) {
                        break;
                    }
                }
            }
            eventOK = eventOK && SunDragSourceContextPeer.checkEvent(event);
            if (!eventOK) {
                event.consume();
            }
        }
        while (eventOK == false);

        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
            eventLog.finest("Dispatching: " + event);
        }

        Object handle = null;
        if (delegate != null) {
            handle = delegate.beforeDispatch(event);
        }
        eq.dispatchEvent(event);
        if (delegate != null) {
            delegate.afterDispatch(event, handle);
        }
    }
    catch (ThreadDeath death) {
        doDispatch = false;
        throw death;
    }
    catch (InterruptedException interruptedException) {
        doDispatch = false; // AppContext.dispose() interrupts all
                            // Threads in the AppContext
    }
    catch (Throwable e) {
        processException(e);
    }
}