1 /* 2 * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.awt; 27 28 import sun.awt.AppContext; 29 import sun.awt.SunToolkit; 30 31 /** 32 * A wrapping tag for a nested AWTEvent which indicates that the event was 33 * sent from another AppContext. The destination AppContext should handle the 34 * event even if it is currently blocked waiting for a SequencedEvent or 35 * another SentEvent to be handled. 36 * 37 * @author David Mendenhall 38 */ 39 class SentEvent extends AWTEvent implements ActiveEvent { 40 /* 41 * serialVersionUID 42 */ 43 private static final long serialVersionUID = -383615247028828931L; 44 45 static final int ID = 46 java.awt.event.FocusEvent.FOCUS_LAST + 2; 47 48 boolean dispatched; 49 private AWTEvent nested; 50 @SuppressWarnings("serial") // Not statically typed as Serializable 51 private AppContext toNotify; 52 53 SentEvent() { 54 this(null); 55 } 56 SentEvent(AWTEvent nested) { 57 this(nested, null); 58 } 59 SentEvent(AWTEvent nested, AppContext toNotify) { 60 super((nested != null) 61 ? nested.getSource() 62 : Toolkit.getDefaultToolkit(), 63 ID); 64 this.nested = nested; 65 this.toNotify = toNotify; 66 } 67 68 public void dispatch() { 69 try { 70 if (nested != null) { 71 Toolkit.getEventQueue().dispatchEvent(nested); 72 } 73 } finally { 74 dispatched = true; 75 if (toNotify != null) { 76 SunToolkit.postEvent(toNotify, new SentEvent()); 77 } 78 synchronized (this) { 79 notifyAll(); 80 } 81 } 82 } 83 final void dispose() { 84 dispatched = true; 85 if (toNotify != null) { 86 SunToolkit.postEvent(toNotify, new SentEvent()); 87 } 88 synchronized (this) { 89 notifyAll(); 90 } 91 } 92 }