Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/awt/EventQueueDelegate.java
38827 views
/*1* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.awt;2627import java.awt.AWTEvent;28import java.awt.EventQueue;293031public class EventQueueDelegate {32private static final Object EVENT_QUEUE_DELEGATE_KEY =33new StringBuilder("EventQueueDelegate.Delegate");3435public static void setDelegate(Delegate delegate) {36AppContext.getAppContext().put(EVENT_QUEUE_DELEGATE_KEY, delegate);37}38public static Delegate getDelegate() {39return40(Delegate) AppContext.getAppContext().get(EVENT_QUEUE_DELEGATE_KEY);41}42public interface Delegate {43/**44* This method allows for changing {@code EventQueue} events order.45*46* @param eventQueue current {@code EventQueue}47* @return next {@code event} for the {@code EventDispatchThread}48*/4950public AWTEvent getNextEvent(EventQueue eventQueue) throws InterruptedException;5152/**53* Notifies delegate before EventQueue.dispatch method.54*55* Note: this method may mutate the event56*57* @param event to be dispatched by {@code dispatch} method58* @return handle to be passed to {@code afterDispatch} method59*/60public Object beforeDispatch(AWTEvent event) throws InterruptedException;6162/**63* Notifies delegate after EventQueue.dispatch method.64*65* @param event {@code event} dispatched by the {@code dispatch} method66* @param handle object which came from {@code beforeDispatch} method67*/68public void afterDispatch(AWTEvent event, Object handle) throws InterruptedException;69}70}717273