1 /*
2 * Copyright (c) 1996, 2014, 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 java.util.EventObject;
29 import java.awt.event.*;
30 import java.awt.peer.ComponentPeer;
31 import java.awt.peer.LightweightPeer;
32 import java.lang.reflect.Field;
33 import sun.awt.AWTAccessor;
34 import sun.util.logging.PlatformLogger;
35
36 import java.security.AccessControlContext;
37 import java.security.AccessController;
38
39 /**
40 * The root event class for all AWT events.
41 * This class and its subclasses supersede the original
42 * java.awt.Event class.
43 * Subclasses of this root AWTEvent class defined outside of the
44 * java.awt.event package should define event ID values greater than
45 * the value defined by RESERVED_ID_MAX.
46 * <p>
47 * The event masks defined in this class are needed by Component subclasses
48 * which are using Component.enableEvents() to select for event types not
49 * selected by registered listeners. If a listener is registered on a
50 * component, the appropriate event mask is already set internally by the
51 * component.
52 * <p>
53 * The masks are also used to specify to which types of events an
54 * AWTEventListener should listen. The masks are bitwise-ORed together
55 * and passed to Toolkit.addAWTEventListener.
56 *
57 * @see Component#enableEvents
61 * @see java.awt.event.AdjustmentEvent
62 * @see java.awt.event.ComponentEvent
63 * @see java.awt.event.ContainerEvent
64 * @see java.awt.event.FocusEvent
65 * @see java.awt.event.InputMethodEvent
66 * @see java.awt.event.InvocationEvent
67 * @see java.awt.event.ItemEvent
68 * @see java.awt.event.HierarchyEvent
69 * @see java.awt.event.KeyEvent
70 * @see java.awt.event.MouseEvent
71 * @see java.awt.event.MouseWheelEvent
72 * @see java.awt.event.PaintEvent
73 * @see java.awt.event.TextEvent
74 * @see java.awt.event.WindowEvent
75 *
76 * @author Carl Quinn
77 * @author Amy Fowler
78 * @since 1.1
79 */
80 public abstract class AWTEvent extends EventObject {
81 private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.AWTEvent");
82 private byte bdata[];
83
84 /**
85 * The event's id.
86 * @serial
87 * @see #getID()
88 * @see #AWTEvent
89 */
90 protected int id;
91
92 /**
93 * Controls whether or not the event is sent back down to the peer once the
94 * source has processed it - false means it's sent to the peer; true means
95 * it's not. Semantic events always have a 'true' value since they were
96 * generated by the peer in response to a low-level event.
97 * @serial
98 * @see #consume
99 * @see #isConsumed
100 */
101 protected boolean consumed = false;
224 */
225 public static final long WINDOW_STATE_EVENT_MASK = 0x40000;
226
227 /**
228 * The event mask for selecting window focus events.
229 * @since 1.4
230 */
231 public static final long WINDOW_FOCUS_EVENT_MASK = 0x80000;
232
233 /**
234 * WARNING: there are more mask defined privately. See
235 * SunToolkit.GRAB_EVENT_MASK.
236 */
237
238 /**
239 * The maximum value for reserved AWT event IDs. Programs defining
240 * their own event IDs should use IDs greater than this value.
241 */
242 public static final int RESERVED_ID_MAX = 1999;
243
244 // security stuff
245 private static Field inputEvent_CanAccessSystemClipboard_Field = null;
246
247 /*
248 * JDK 1.1 serialVersionUID
249 */
250 private static final long serialVersionUID = -1825314779160409405L;
251
252 static {
253 /* ensure that the necessary native libraries are loaded */
254 Toolkit.loadLibraries();
255 if (!GraphicsEnvironment.isHeadless()) {
256 initIDs();
257 }
258 AWTAccessor.setAWTEventAccessor(
259 new AWTAccessor.AWTEventAccessor() {
260 public void setPosted(AWTEvent ev) {
261 ev.isPosted = true;
262 }
263
264 public void setSystemGenerated(AWTEvent ev) {
265 ev.isSystemGenerated = true;
266 }
|
1 /*
2 * Copyright (c) 1996, 2017, 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 java.awt.event.ActionEvent;
29 import java.awt.event.AdjustmentEvent;
30 import java.awt.event.ComponentEvent;
31 import java.awt.event.FocusEvent;
32 import java.awt.event.InputEvent;
33 import java.awt.event.InputMethodEvent;
34 import java.awt.event.ItemEvent;
35 import java.awt.event.KeyEvent;
36 import java.awt.event.MouseEvent;
37 import java.awt.event.TextEvent;
38 import java.awt.event.WindowEvent;
39 import java.awt.peer.ComponentPeer;
40 import java.awt.peer.LightweightPeer;
41 import java.security.AccessControlContext;
42 import java.security.AccessController;
43 import java.util.EventObject;
44
45 import sun.awt.AWTAccessor;
46
47 /**
48 * The root event class for all AWT events.
49 * This class and its subclasses supersede the original
50 * java.awt.Event class.
51 * Subclasses of this root AWTEvent class defined outside of the
52 * java.awt.event package should define event ID values greater than
53 * the value defined by RESERVED_ID_MAX.
54 * <p>
55 * The event masks defined in this class are needed by Component subclasses
56 * which are using Component.enableEvents() to select for event types not
57 * selected by registered listeners. If a listener is registered on a
58 * component, the appropriate event mask is already set internally by the
59 * component.
60 * <p>
61 * The masks are also used to specify to which types of events an
62 * AWTEventListener should listen. The masks are bitwise-ORed together
63 * and passed to Toolkit.addAWTEventListener.
64 *
65 * @see Component#enableEvents
69 * @see java.awt.event.AdjustmentEvent
70 * @see java.awt.event.ComponentEvent
71 * @see java.awt.event.ContainerEvent
72 * @see java.awt.event.FocusEvent
73 * @see java.awt.event.InputMethodEvent
74 * @see java.awt.event.InvocationEvent
75 * @see java.awt.event.ItemEvent
76 * @see java.awt.event.HierarchyEvent
77 * @see java.awt.event.KeyEvent
78 * @see java.awt.event.MouseEvent
79 * @see java.awt.event.MouseWheelEvent
80 * @see java.awt.event.PaintEvent
81 * @see java.awt.event.TextEvent
82 * @see java.awt.event.WindowEvent
83 *
84 * @author Carl Quinn
85 * @author Amy Fowler
86 * @since 1.1
87 */
88 public abstract class AWTEvent extends EventObject {
89
90 private byte bdata[];
91
92 /**
93 * The event's id.
94 * @serial
95 * @see #getID()
96 * @see #AWTEvent
97 */
98 protected int id;
99
100 /**
101 * Controls whether or not the event is sent back down to the peer once the
102 * source has processed it - false means it's sent to the peer; true means
103 * it's not. Semantic events always have a 'true' value since they were
104 * generated by the peer in response to a low-level event.
105 * @serial
106 * @see #consume
107 * @see #isConsumed
108 */
109 protected boolean consumed = false;
232 */
233 public static final long WINDOW_STATE_EVENT_MASK = 0x40000;
234
235 /**
236 * The event mask for selecting window focus events.
237 * @since 1.4
238 */
239 public static final long WINDOW_FOCUS_EVENT_MASK = 0x80000;
240
241 /**
242 * WARNING: there are more mask defined privately. See
243 * SunToolkit.GRAB_EVENT_MASK.
244 */
245
246 /**
247 * The maximum value for reserved AWT event IDs. Programs defining
248 * their own event IDs should use IDs greater than this value.
249 */
250 public static final int RESERVED_ID_MAX = 1999;
251
252 /*
253 * JDK 1.1 serialVersionUID
254 */
255 private static final long serialVersionUID = -1825314779160409405L;
256
257 static {
258 /* ensure that the necessary native libraries are loaded */
259 Toolkit.loadLibraries();
260 if (!GraphicsEnvironment.isHeadless()) {
261 initIDs();
262 }
263 AWTAccessor.setAWTEventAccessor(
264 new AWTAccessor.AWTEventAccessor() {
265 public void setPosted(AWTEvent ev) {
266 ev.isPosted = true;
267 }
268
269 public void setSystemGenerated(AWTEvent ev) {
270 ev.isSystemGenerated = true;
271 }
|