01 /*
02 * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
03 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04 *
05 * This code is free software; you can redistribute it and/or modify it
06 * under the terms of the GNU General Public License version 2 only, as
07 * published by the Free Software Foundation. Sun designates this
08 * particular file as subject to the "Classpath" exception as provided
09 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any 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 * @version 1.16, 06/05/07
38 * @author David Mendenhall
39 */
40 class SentEvent extends AWTEvent implements ActiveEvent {
41 /*
42 * serialVersionUID
43 */
44 private static final long serialVersionUID = -383615247028828931L;
45
46 static final int ID = java.awt.event.FocusEvent.FOCUS_LAST + 2;
47
48 boolean dispatched;
49 private AWTEvent nested;
50 private AppContext toNotify;
51
52 SentEvent() {
53 this (null);
54 }
55
56 SentEvent(AWTEvent nested) {
57 this (nested, null);
58 }
59
60 SentEvent(AWTEvent nested, AppContext toNotify) {
61 super ((nested != null) ? nested.getSource() : Toolkit
62 .getDefaultToolkit(), ID);
63 this .nested = nested;
64 this .toNotify = toNotify;
65 }
66
67 public void dispatch() {
68 try {
69 if (nested != null) {
70 Toolkit.getEventQueue().dispatchEvent(nested);
71 }
72 } finally {
73 dispatched = true;
74 if (toNotify != null) {
75 SunToolkit.postEvent(toNotify, new SentEvent());
76 }
77 synchronized (this ) {
78 notifyAll();
79 }
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 }
|