History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/java/awt/event (91 of 18352 files). Show all

Unified · Split

91 files
  1. java/pkg/java/awt/event/AWTEventListener.class +0 −0
  2. java/pkg/java/awt/event/AWTEventListener.java +62 −0
  3. java/pkg/java/awt/event/AWTEventListenerProxy.class +0 −0
  4. java/pkg/java/awt/event/AWTEventListenerProxy.java +81 −0
  5. java/pkg/java/awt/event/ActionEvent.class +0 −0
  6. java/pkg/java/awt/event/ActionEvent.java +288 −0
  7. java/pkg/java/awt/event/ActionListener.class +0 −0
  8. java/pkg/java/awt/event/ActionListener.java +52 −0
  9. java/pkg/java/awt/event/AdjustmentEvent.class +0 −0
  10. java/pkg/java/awt/event/AdjustmentEvent.java +289 −0
  11. java/pkg/java/awt/event/AdjustmentListener.class +0 −0
  12. java/pkg/java/awt/event/AdjustmentListener.java +43 −0
  13. java/pkg/java/awt/event/ComponentAdapter.class +0 −0
  14. java/pkg/java/awt/event/ComponentAdapter.java +72 −0
  15. java/pkg/java/awt/event/ComponentEvent.class +0 −0
  16. java/pkg/java/awt/event/ComponentEvent.java +165 −0
  17. java/pkg/java/awt/event/ComponentListener.class +0 −0
  18. java/pkg/java/awt/event/ComponentListener.java +74 −0
  19. java/pkg/java/awt/event/ContainerAdapter.class +0 −0
  20. java/pkg/java/awt/event/ContainerAdapter.java +62 −0
  21. java/pkg/java/awt/event/ContainerEvent.class +0 −0
  22. java/pkg/java/awt/event/ContainerEvent.java +159 −0
  23. java/pkg/java/awt/event/ContainerListener.class +0 −0
  24. java/pkg/java/awt/event/ContainerListener.java +66 −0
  25. java/pkg/java/awt/event/FocusAdapter.class +0 −0
  26. java/pkg/java/awt/event/FocusAdapter.java +62 −0
  27. java/pkg/java/awt/event/FocusEvent.class +0 −0
  28. java/pkg/java/awt/event/FocusEvent.java +249 −0
  29. java/pkg/java/awt/event/FocusListener.class +0 −0
  30. java/pkg/java/awt/event/FocusListener.java +61 −0
  31. java/pkg/java/awt/event/HierarchyBoundsAdapter.class +0 −0
  32. java/pkg/java/awt/event/HierarchyBoundsAdapter.java +61 −0
  33. java/pkg/java/awt/event/HierarchyBoundsListener.class +0 −0
  34. java/pkg/java/awt/event/HierarchyBoundsListener.java +62 −0
  35. java/pkg/java/awt/event/HierarchyEvent.class +0 −0
  36. java/pkg/java/awt/event/HierarchyEvent.java +337 −0
  37. java/pkg/java/awt/event/HierarchyListener.class +0 −0
  38. java/pkg/java/awt/event/HierarchyListener.java +57 −0
  39. java/pkg/java/awt/event/InputEvent$1.class +0 −0
  40. java/pkg/java/awt/event/InputEvent.class +0 −0
  41. java/pkg/java/awt/event/InputEvent.java +527 −0
  42. java/pkg/java/awt/event/InputMethodEvent.class +0 −0
  43. java/pkg/java/awt/event/InputMethodEvent.java +416 −0
  44. java/pkg/java/awt/event/InputMethodListener.class +0 −0
  45. java/pkg/java/awt/event/InputMethodListener.java +56 −0
  46. java/pkg/java/awt/event/InvocationEvent.class +0 −0
  47. java/pkg/java/awt/event/InvocationEvent.java +351 −0
  48. java/pkg/java/awt/event/ItemEvent.class +0 −0
  49. java/pkg/java/awt/event/ItemEvent.java +202 −0
  50. java/pkg/java/awt/event/ItemListener.class +0 −0
  51. java/pkg/java/awt/event/ItemListener.java +56 −0
  52. java/pkg/java/awt/event/KeyAdapter.class +0 −0
  53. java/pkg/java/awt/event/KeyAdapter.java +69 −0
  54. java/pkg/java/awt/event/KeyEvent.class +0 −0
  55. java/pkg/java/awt/event/KeyEvent.java +1669 −0
  56. java/pkg/java/awt/event/KeyListener.class +0 −0
  57. java/pkg/java/awt/event/KeyListener.java +73 −0
  58. java/pkg/java/awt/event/MouseAdapter.class +0 −0
  59. java/pkg/java/awt/event/MouseAdapter.java +113 −0
  60. java/pkg/java/awt/event/MouseEvent.class +0 −0
  61. java/pkg/java/awt/event/MouseEvent.java +1171 −0
  62. java/pkg/java/awt/event/MouseListener.class +0 −0
  63. java/pkg/java/awt/event/MouseListener.java +84 −0
  64. java/pkg/java/awt/event/MouseMotionAdapter.class +0 −0
  65. java/pkg/java/awt/event/MouseMotionAdapter.java +71 −0
  66. java/pkg/java/awt/event/MouseMotionListener.class +0 −0
  67. java/pkg/java/awt/event/MouseMotionListener.java +75 −0
  68. java/pkg/java/awt/event/MouseWheelEvent.class +0 −0
  69. java/pkg/java/awt/event/MouseWheelEvent.java +447 −0
  70. java/pkg/java/awt/event/MouseWheelListener.class +0 −0
  71. java/pkg/java/awt/event/MouseWheelListener.java +58 −0
  72. java/pkg/java/awt/event/NativeLibLoader.class +0 −0
  73. java/pkg/java/awt/event/NativeLibLoader.java +59 −0
  74. java/pkg/java/awt/event/PaintEvent.class +0 −0
  75. java/pkg/java/awt/event/PaintEvent.java +139 −0
  76. java/pkg/java/awt/event/TextEvent.class +0 −0
  77. java/pkg/java/awt/event/TextEvent.java +113 −0
  78. java/pkg/java/awt/event/TextListener.class +0 −0
  79. java/pkg/java/awt/event/TextListener.java +55 −0
  80. java/pkg/java/awt/event/WindowAdapter.class +0 −0
  81. java/pkg/java/awt/event/WindowAdapter.java +117 −0
  82. java/pkg/java/awt/event/WindowEvent.class +0 −0
  83. java/pkg/java/awt/event/WindowEvent.java +428 −0
  84. java/pkg/java/awt/event/WindowFocusListener.class +0 −0
  85. java/pkg/java/awt/event/WindowFocusListener.java +69 −0
  86. java/pkg/java/awt/event/WindowListener.class +0 −0
  87. java/pkg/java/awt/event/WindowListener.java +103 −0
  88. java/pkg/java/awt/event/WindowStateListener.class +0 −0
  89. java/pkg/java/awt/event/WindowStateListener.java +55 −0
  90. java/pkg/java/awt/event/mkfile +51 −0
  91. java/pkg/java/awt/event/package.html +57 −0
java/pkg/java/awt/event/AWTEventListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/AWTEventListener.java+62−0
@@ -0,0 +1,62 @@
1+/*
2+ * Copyright (c) 1998, 2003, 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.event;
27+
28+import java.util.EventListener;
29+import java.awt.AWTEvent;
30+
31+/**
32+ * The listener interface for receiving notification of events
33+ * dispatched to objects that are instances of Component or
34+ * MenuComponent or their subclasses. Unlike the other EventListeners
35+ * in this package, AWTEventListeners passively observe events
36+ * being dispatched in the AWT, system-wide. Most applications
37+ * should never use this class; applications which might use
38+ * AWTEventListeners include event recorders for automated testing,
39+ * and facilities such as the Java Accessibility package.
40+ * <p>
41+ * The class that is interested in monitoring AWT events
42+ * implements this interface, and the object created with that
43+ * class is registered with the Toolkit, using the Toolkit's
44+ * <code>addAWTEventListener</code> method. When an event is
45+ * dispatched anywhere in the AWT, that object's
46+ * <code>eventDispatched</code> method is invoked.
47+ *
48+ * @see java.awt.AWTEvent
49+ * @see java.awt.Toolkit#addAWTEventListener
50+ * @see java.awt.Toolkit#removeAWTEventListener
51+ *
52+ * @author Fred Ecks
53+ * @since 1.2
54+ */
55+public interface AWTEventListener extends EventListener {
56+
57+ /**
58+ * Invoked when an event is dispatched in the AWT.
59+ */
60+ public void eventDispatched(AWTEvent event);
61+
62+}
java/pkg/java/awt/event/AWTEventListenerProxy.class+0−0

Binary file not shown.

java/pkg/java/awt/event/AWTEventListenerProxy.java+81−0
@@ -0,0 +1,81 @@
1+/*
2+ * Copyright (c) 2001, 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.event;
27+
28+import java.util.EventListenerProxy;
29+import java.awt.AWTEvent;
30+
31+/**
32+ * A class which extends the {@code EventListenerProxy}
33+ * specifically for adding an {@code AWTEventListener}
34+ * for a specific event mask.
35+ * Instances of this class can be added as {@code AWTEventListener}s
36+ * to a {@code Toolkit} object.
37+ * <p>
38+ * The {@code getAWTEventListeners} method of {@code Toolkit}
39+ * can return a mixture of {@code AWTEventListener}
40+ * and {@code AWTEventListenerProxy} objects.
41+ *
42+ * @see java.awt.Toolkit
43+ * @see java.util.EventListenerProxy
44+ * @since 1.4
45+ */
46+public class AWTEventListenerProxy
47+ extends EventListenerProxy<AWTEventListener>
48+ implements AWTEventListener {
49+
50+ private final long eventMask;
51+
52+ /**
53+ * Constructor which binds the {@code AWTEventListener}
54+ * to a specific event mask.
55+ *
56+ * @param eventMask the bitmap of event types to receive
57+ * @param listener the listener object
58+ */
59+ public AWTEventListenerProxy (long eventMask, AWTEventListener listener) {
60+ super(listener);
61+ this.eventMask = eventMask;
62+ }
63+
64+ /**
65+ * Forwards the AWT event to the listener delegate.
66+ *
67+ * @param event the AWT event
68+ */
69+ public void eventDispatched(AWTEvent event) {
70+ getListener().eventDispatched(event);
71+ }
72+
73+ /**
74+ * Returns the event mask associated with the listener.
75+ *
76+ * @return the event mask associated with the listener
77+ */
78+ public long getEventMask() {
79+ return this.eventMask;
80+ }
81+}
java/pkg/java/awt/event/ActionEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/ActionEvent.java+288−0
@@ -0,0 +1,288 @@
1+/*
2+ * Copyright (c) 1996, 2010, 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.event;
27+
28+import java.awt.AWTEvent;
29+import java.awt.Event;
30+
31+/**
32+ * A semantic event which indicates that a component-defined action occurred.
33+ * This high-level event is generated by a component (such as a
34+ * <code>Button</code>) when
35+ * the component-specific action occurs (such as being pressed).
36+ * The event is passed to every <code>ActionListener</code> object
37+ * that registered to receive such events using the component's
38+ * <code>addActionListener</code> method.
39+ * <p>
40+ * <b>Note:</b> To invoke an <code>ActionEvent</code> on a
41+ * <code>Button</code> using the keyboard, use the Space bar.
42+ * <P>
43+ * The object that implements the <code>ActionListener</code> interface
44+ * gets this <code>ActionEvent</code> when the event occurs. The listener
45+ * is therefore spared the details of processing individual mouse movements
46+ * and mouse clicks, and can instead process a "meaningful" (semantic)
47+ * event like "button pressed".
48+ * <p>
49+ * An unspecified behavior will be caused if the {@code id} parameter
50+ * of any particular {@code ActionEvent} instance is not
51+ * in the range from {@code ACTION_FIRST} to {@code ACTION_LAST}.
52+ *
53+ * @see ActionListener
54+ * @see <a href="http://java.sun.com/docs/books/tutorial/uiswing/events/actionlistener.html">Tutorial: How to Write an Action Listener</a>
55+ *
56+ * @author Carl Quinn
57+ * @since 1.1
58+ */
59+public class ActionEvent extends AWTEvent {
60+
61+ /**
62+ * The shift modifier. An indicator that the shift key was held
63+ * down during the event.
64+ */
65+ public static final int SHIFT_MASK = Event.SHIFT_MASK;
66+
67+ /**
68+ * The control modifier. An indicator that the control key was held
69+ * down during the event.
70+ */
71+ public static final int CTRL_MASK = Event.CTRL_MASK;
72+
73+ /**
74+ * The meta modifier. An indicator that the meta key was held
75+ * down during the event.
76+ */
77+ public static final int META_MASK = Event.META_MASK;
78+
79+ /**
80+ * The alt modifier. An indicator that the alt key was held
81+ * down during the event.
82+ */
83+ public static final int ALT_MASK = Event.ALT_MASK;
84+
85+
86+ /**
87+ * The first number in the range of ids used for action events.
88+ */
89+ public static final int ACTION_FIRST = 1001;
90+
91+ /**
92+ * The last number in the range of ids used for action events.
93+ */
94+ public static final int ACTION_LAST = 1001;
95+
96+ /**
97+ * This event id indicates that a meaningful action occured.
98+ */
99+ public static final int ACTION_PERFORMED = ACTION_FIRST; //Event.ACTION_EVENT
100+
101+ /**
102+ * The nonlocalized string that gives more details
103+ * of what actually caused the event.
104+ * This information is very specific to the component
105+ * that fired it.
106+
107+ * @serial
108+ * @see #getActionCommand
109+ */
110+ String actionCommand;
111+
112+ /**
113+ * Timestamp of when this event occurred. Because an ActionEvent is a high-
114+ * level, semantic event, the timestamp is typically the same as an
115+ * underlying InputEvent.
116+ *
117+ * @serial
118+ * @see #getWhen
119+ */
120+ long when;
121+
122+ /**
123+ * This represents the key modifier that was selected,
124+ * and is used to determine the state of the selected key.
125+ * If no modifier has been selected it will default to
126+ * zero.
127+ *
128+ * @serial
129+ * @see #getModifiers
130+ */
131+ int modifiers;
132+
133+ /*
134+ * JDK 1.1 serialVersionUID
135+ */
136+ private static final long serialVersionUID = -7671078796273832149L;
137+
138+ /**
139+ * Constructs an <code>ActionEvent</code> object.
140+ * <p>
141+ * This method throws an
142+ * <code>IllegalArgumentException</code> if <code>source</code>
143+ * is <code>null</code>.
144+ * A <code>null</code> <code>command</code> string is legal,
145+ * but not recommended.
146+ *
147+ * @param source The object that originated the event
148+ * @param id An integer that identifies the event.
149+ * For information on allowable values, see
150+ * the class description for {@link ActionEvent}
151+ * @param command A string that may specify a command (possibly one
152+ * of several) associated with the event
153+ * @throws IllegalArgumentException if <code>source</code> is null
154+ * @see #getSource()
155+ * @see #getID()
156+ * @see #getActionCommand()
157+ */
158+ public ActionEvent(Object source, int id, String command) {
159+ this(source, id, command, 0);
160+ }
161+
162+ /**
163+ * Constructs an <code>ActionEvent</code> object with modifier keys.
164+ * <p>
165+ * This method throws an
166+ * <code>IllegalArgumentException</code> if <code>source</code>
167+ * is <code>null</code>.
168+ * A <code>null</code> <code>command</code> string is legal,
169+ * but not recommended.
170+ *
171+ * @param source The object that originated the event
172+ * @param id An integer that identifies the event.
173+ * For information on allowable values, see
174+ * the class description for {@link ActionEvent}
175+ * @param command A string that may specify a command (possibly one
176+ * of several) associated with the event
177+ * @param modifiers The modifier keys down during event
178+ * (shift, ctrl, alt, meta).
179+ * Passing negative parameter is not recommended.
180+ * Zero value means that no modifiers were passed
181+ * @throws IllegalArgumentException if <code>source</code> is null
182+ * @see #getSource()
183+ * @see #getID()
184+ * @see #getActionCommand()
185+ * @see #getModifiers()
186+ */
187+ public ActionEvent(Object source, int id, String command, int modifiers) {
188+ this(source, id, command, 0, modifiers);
189+ }
190+
191+ /**
192+ * Constructs an <code>ActionEvent</code> object with the specified
193+ * modifier keys and timestamp.
194+ * <p>
195+ * This method throws an
196+ * <code>IllegalArgumentException</code> if <code>source</code>
197+ * is <code>null</code>.
198+ * A <code>null</code> <code>command</code> string is legal,
199+ * but not recommended.
200+ *
201+ * @param source The object that originated the event
202+ * @param id An integer that identifies the event.
203+ * For information on allowable values, see
204+ * the class description for {@link ActionEvent}
205+ * @param command A string that may specify a command (possibly one
206+ * of several) associated with the event
207+ * @param modifiers The modifier keys down during event
208+ * (shift, ctrl, alt, meta).
209+ * Passing negative parameter is not recommended.
210+ * Zero value means that no modifiers were passed
211+ * @param when A long that gives the time the event occurred.
212+ * Passing negative or zero value
213+ * is not recommended
214+ * @throws IllegalArgumentException if <code>source</code> is null
215+ * @see #getSource()
216+ * @see #getID()
217+ * @see #getActionCommand()
218+ * @see #getModifiers()
219+ * @see #getWhen()
220+ *
221+ * @since 1.4
222+ */
223+ public ActionEvent(Object source, int id, String command, long when,
224+ int modifiers) {
225+ super(source, id);
226+ this.actionCommand = command;
227+ this.when = when;
228+ this.modifiers = modifiers;
229+ }
230+
231+ /**
232+ * Returns the command string associated with this action.
233+ * This string allows a "modal" component to specify one of several
234+ * commands, depending on its state. For example, a single button might
235+ * toggle between "show details" and "hide details". The source object
236+ * and the event would be the same in each case, but the command string
237+ * would identify the intended action.
238+ * <p>
239+ * Note that if a <code>null</code> command string was passed
240+ * to the constructor for this <code>ActionEvent</code>, this
241+ * this method returns <code>null</code>.
242+ *
243+ * @return the string identifying the command for this event
244+ */
245+ public String getActionCommand() {
246+ return actionCommand;
247+ }
248+
249+ /**
250+ * Returns the timestamp of when this event occurred. Because an
251+ * ActionEvent is a high-level, semantic event, the timestamp is typically
252+ * the same as an underlying InputEvent.
253+ *
254+ * @return this event's timestamp
255+ * @since 1.4
256+ */
257+ public long getWhen() {
258+ return when;
259+ }
260+
261+ /**
262+ * Returns the modifier keys held down during this action event.
263+ *
264+ * @return the bitwise-or of the modifier constants
265+ */
266+ public int getModifiers() {
267+ return modifiers;
268+ }
269+
270+ /**
271+ * Returns a parameter string identifying this action event.
272+ * This method is useful for event-logging and for debugging.
273+ *
274+ * @return a string identifying the event and its associated command
275+ */
276+ public String paramString() {
277+ String typeStr;
278+ switch(id) {
279+ case ACTION_PERFORMED:
280+ typeStr = "ACTION_PERFORMED";
281+ break;
282+ default:
283+ typeStr = "unknown type";
284+ }
285+ return typeStr + ",cmd="+actionCommand+",when="+when+",modifiers="+
286+ KeyEvent.getKeyModifiersText(modifiers);
287+ }
288+}
java/pkg/java/awt/event/ActionListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/ActionListener.java+52−0
@@ -0,0 +1,52 @@
1+/*
2+ * Copyright (c) 1996, 2006, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving action events.
32+ * The class that is interested in processing an action event
33+ * implements this interface, and the object created with that
34+ * class is registered with a component, using the component's
35+ * <code>addActionListener</code> method. When the action event
36+ * occurs, that object's <code>actionPerformed</code> method is
37+ * invoked.
38+ *
39+ * @see ActionEvent
40+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/eventmodel.html">Tutorial: Java 1.1 Event Model</a>
41+ *
42+ * @author Carl Quinn
43+ * @since 1.1
44+ */
45+public interface ActionListener extends EventListener {
46+
47+ /**
48+ * Invoked when an action occurs.
49+ */
50+ public void actionPerformed(ActionEvent e);
51+
52+}
java/pkg/java/awt/event/AdjustmentEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/AdjustmentEvent.java+289−0
@@ -0,0 +1,289 @@
1+/*
2+ * Copyright (c) 1996, 2008, 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.event;
27+
28+import java.awt.Adjustable;
29+import java.awt.AWTEvent;
30+
31+/**
32+ * The adjustment event emitted by Adjustable objects like
33+ * {@link java.awt.Scrollbar} and {@link java.awt.ScrollPane}.
34+ * When the user changes the value of the scrolling component,
35+ * it receives an instance of {@code AdjustmentEvent}.
36+ * <p>
37+ * An unspecified behavior will be caused if the {@code id} parameter
38+ * of any particular {@code AdjustmentEvent} instance is not
39+ * in the range from {@code ADJUSTMENT_FIRST} to {@code ADJUSTMENT_LAST}.
40+ * <p>
41+ * The {@code type} of any {@code AdjustmentEvent} instance takes one of the following
42+ * values:
43+ * <ul>
44+ * <li> {@code UNIT_INCREMENT}
45+ * <li> {@code UNIT_DECREMENT}
46+ * <li> {@code BLOCK_INCREMENT}
47+ * <li> {@code BLOCK_DECREMENT}
48+ * <li> {@code TRACK}
49+ * </ul>
50+ * Assigning the value different from listed above will cause an unspecified behavior.
51+ * @see java.awt.Adjustable
52+ * @see AdjustmentListener
53+ *
54+ * @author Amy Fowler
55+ * @since 1.1
56+ */
57+public class AdjustmentEvent extends AWTEvent {
58+
59+ /**
60+ * Marks the first integer id for the range of adjustment event ids.
61+ */
62+ public static final int ADJUSTMENT_FIRST = 601;
63+
64+ /**
65+ * Marks the last integer id for the range of adjustment event ids.
66+ */
67+ public static final int ADJUSTMENT_LAST = 601;
68+
69+ /**
70+ * The adjustment value changed event.
71+ */
72+ public static final int ADJUSTMENT_VALUE_CHANGED = ADJUSTMENT_FIRST; //Event.SCROLL_LINE_UP
73+
74+ /**
75+ * The unit increment adjustment type.
76+ */
77+ public static final int UNIT_INCREMENT = 1;
78+
79+ /**
80+ * The unit decrement adjustment type.
81+ */
82+ public static final int UNIT_DECREMENT = 2;
83+
84+ /**
85+ * The block decrement adjustment type.
86+ */
87+ public static final int BLOCK_DECREMENT = 3;
88+
89+ /**
90+ * The block increment adjustment type.
91+ */
92+ public static final int BLOCK_INCREMENT = 4;
93+
94+ /**
95+ * The absolute tracking adjustment type.
96+ */
97+ public static final int TRACK = 5;
98+
99+ /**
100+ * The adjustable object that fired the event.
101+ *
102+ * @serial
103+ * @see #getAdjustable
104+ */
105+ Adjustable adjustable;
106+
107+ /**
108+ * <code>value</code> will contain the new value of the
109+ * adjustable object. This value will always be in a
110+ * range associated adjustable object.
111+ *
112+ * @serial
113+ * @see #getValue
114+ */
115+ int value;
116+
117+ /**
118+ * The <code>adjustmentType</code> describes how the adjustable
119+ * object value has changed.
120+ * This value can be increased/decreased by a block or unit amount
121+ * where the block is associated with page increments/decrements,
122+ * and a unit is associated with line increments/decrements.
123+ *
124+ * @serial
125+ * @see #getAdjustmentType
126+ */
127+ int adjustmentType;
128+
129+
130+ /**
131+ * The <code>isAdjusting</code> is true if the event is one
132+ * of the series of multiple adjustment events.
133+ *
134+ * @since 1.4
135+ * @serial
136+ * @see #getValueIsAdjusting
137+ */
138+ boolean isAdjusting;
139+
140+
141+ /*
142+ * JDK 1.1 serialVersionUID
143+ */
144+ private static final long serialVersionUID = 5700290645205279921L;
145+
146+
147+ /**
148+ * Constructs an <code>AdjustmentEvent</code> object with the
149+ * specified <code>Adjustable</code> source, event type,
150+ * adjustment type, and value.
151+ * <p> This method throws an
152+ * <code>IllegalArgumentException</code> if <code>source</code>
153+ * is <code>null</code>.
154+ *
155+ * @param source The <code>Adjustable</code> object where the
156+ * event originated
157+ * @param id An integer indicating the type of event.
158+ * For information on allowable values, see
159+ * the class description for {@link AdjustmentEvent}
160+ * @param type An integer indicating the adjustment type.
161+ * For information on allowable values, see
162+ * the class description for {@link AdjustmentEvent}
163+ * @param value The current value of the adjustment
164+ * @throws IllegalArgumentException if <code>source</code> is null
165+ * @see #getSource()
166+ * @see #getID()
167+ * @see #getAdjustmentType()
168+ * @see #getValue()
169+ */
170+ public AdjustmentEvent(Adjustable source, int id, int type, int value) {
171+ this(source, id, type, value, false);
172+ }
173+
174+ /**
175+ * Constructs an <code>AdjustmentEvent</code> object with the
176+ * specified Adjustable source, event type, adjustment type, and value.
177+ * <p> This method throws an
178+ * <code>IllegalArgumentException</code> if <code>source</code>
179+ * is <code>null</code>.
180+ *
181+ * @param source The <code>Adjustable</code> object where the
182+ * event originated
183+ * @param id An integer indicating the type of event.
184+ * For information on allowable values, see
185+ * the class description for {@link AdjustmentEvent}
186+ * @param type An integer indicating the adjustment type.
187+ * For information on allowable values, see
188+ * the class description for {@link AdjustmentEvent}
189+ * @param value The current value of the adjustment
190+ * @param isAdjusting A boolean that equals <code>true</code> if the event is one
191+ * of a series of multiple adjusting events,
192+ * otherwise <code>false</code>
193+ * @throws IllegalArgumentException if <code>source</code> is null
194+ * @since 1.4
195+ * @see #getSource()
196+ * @see #getID()
197+ * @see #getAdjustmentType()
198+ * @see #getValue()
199+ * @see #getValueIsAdjusting()
200+ */
201+ public AdjustmentEvent(Adjustable source, int id, int type, int value, boolean isAdjusting) {
202+ super(source, id);
203+ adjustable = source;
204+ this.adjustmentType = type;
205+ this.value = value;
206+ this.isAdjusting = isAdjusting;
207+ }
208+
209+ /**
210+ * Returns the <code>Adjustable</code> object where this event originated.
211+ *
212+ * @return the <code>Adjustable</code> object where this event originated
213+ */
214+ public Adjustable getAdjustable() {
215+ return adjustable;
216+ }
217+
218+ /**
219+ * Returns the current value in the adjustment event.
220+ *
221+ * @return the current value in the adjustment event
222+ */
223+ public int getValue() {
224+ return value;
225+ }
226+
227+ /**
228+ * Returns the type of adjustment which caused the value changed
229+ * event. It will have one of the following values:
230+ * <ul>
231+ * <li>{@link #UNIT_INCREMENT}
232+ * <li>{@link #UNIT_DECREMENT}
233+ * <li>{@link #BLOCK_INCREMENT}
234+ * <li>{@link #BLOCK_DECREMENT}
235+ * <li>{@link #TRACK}
236+ * </ul>
237+ * @return one of the adjustment values listed above
238+ */
239+ public int getAdjustmentType() {
240+ return adjustmentType;
241+ }
242+
243+ /**
244+ * Returns <code>true</code> if this is one of multiple
245+ * adjustment events.
246+ *
247+ * @return <code>true</code> if this is one of multiple
248+ * adjustment events, otherwise returns <code>false</code>
249+ * @since 1.4
250+ */
251+ public boolean getValueIsAdjusting() {
252+ return isAdjusting;
253+ }
254+
255+ public String paramString() {
256+ String typeStr;
257+ switch(id) {
258+ case ADJUSTMENT_VALUE_CHANGED:
259+ typeStr = "ADJUSTMENT_VALUE_CHANGED";
260+ break;
261+ default:
262+ typeStr = "unknown type";
263+ }
264+ String adjTypeStr;
265+ switch(adjustmentType) {
266+ case UNIT_INCREMENT:
267+ adjTypeStr = "UNIT_INCREMENT";
268+ break;
269+ case UNIT_DECREMENT:
270+ adjTypeStr = "UNIT_DECREMENT";
271+ break;
272+ case BLOCK_INCREMENT:
273+ adjTypeStr = "BLOCK_INCREMENT";
274+ break;
275+ case BLOCK_DECREMENT:
276+ adjTypeStr = "BLOCK_DECREMENT";
277+ break;
278+ case TRACK:
279+ adjTypeStr = "TRACK";
280+ break;
281+ default:
282+ adjTypeStr = "unknown type";
283+ }
284+ return typeStr
285+ + ",adjType="+adjTypeStr
286+ + ",value="+value
287+ + ",isAdjusting="+isAdjusting;
288+ }
289+}
java/pkg/java/awt/event/AdjustmentListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/AdjustmentListener.java+43−0
@@ -0,0 +1,43 @@
1+/*
2+ * Copyright (c) 1996, 1999, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving adjustment events.
32+ *
33+ * @author Amy Fowler
34+ * @since 1.1
35+ */
36+public interface AdjustmentListener extends EventListener {
37+
38+ /**
39+ * Invoked when the value of the adjustable has changed.
40+ */
41+ public void adjustmentValueChanged(AdjustmentEvent e);
42+
43+}
java/pkg/java/awt/event/ComponentAdapter.class+0−0

Binary file not shown.

java/pkg/java/awt/event/ComponentAdapter.java+72−0
@@ -0,0 +1,72 @@
1+/*
2+ * Copyright (c) 1996, 2006, 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.event;
27+
28+/**
29+ * An abstract adapter class for receiving component events.
30+ * The methods in this class are empty. This class exists as
31+ * convenience for creating listener objects.
32+ * <P>
33+ * Extend this class to create a <code>ComponentEvent</code> listener
34+ * and override the methods for the events of interest. (If you implement the
35+ * <code>ComponentListener</code> interface, you have to define all of
36+ * the methods in it. This abstract class defines null methods for them
37+ * all, so you can only have to define methods for events you care about.)
38+ * <P>
39+ * Create a listener object using your class and then register it with a
40+ * component using the component's <code>addComponentListener</code>
41+ * method. When the component's size, location, or visibility
42+ * changes, the relevant method in the listener object is invoked,
43+ * and the <code>ComponentEvent</code> is passed to it.
44+ *
45+ * @see ComponentEvent
46+ * @see ComponentListener
47+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/componentlistener.html">Tutorial: Writing a Component Listener</a>
48+ *
49+ * @author Carl Quinn
50+ * @since 1.1
51+ */
52+public abstract class ComponentAdapter implements ComponentListener {
53+ /**
54+ * Invoked when the component's size changes.
55+ */
56+ public void componentResized(ComponentEvent e) {}
57+
58+ /**
59+ * Invoked when the component's position changes.
60+ */
61+ public void componentMoved(ComponentEvent e) {}
62+
63+ /**
64+ * Invoked when the component has been made visible.
65+ */
66+ public void componentShown(ComponentEvent e) {}
67+
68+ /**
69+ * Invoked when the component has been made invisible.
70+ */
71+ public void componentHidden(ComponentEvent e) {}
72+}
java/pkg/java/awt/event/ComponentEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/ComponentEvent.java+165−0
@@ -0,0 +1,165 @@
1+/*
2+ * Copyright (c) 1996, 2008, 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.event;
27+
28+import java.awt.AWTEvent;
29+import java.awt.Component;
30+import java.awt.Rectangle;
31+
32+/**
33+ * A low-level event which indicates that a component moved, changed
34+ * size, or changed visibility (also, the root class for the other
35+ * component-level events).
36+ * <P>
37+ * Component events are provided for notification purposes ONLY;
38+ * The AWT will automatically handle component moves and resizes
39+ * internally so that GUI layout works properly regardless of
40+ * whether a program is receiving these events or not.
41+ * <P>
42+ * In addition to serving as the base class for other component-related
43+ * events (InputEvent, FocusEvent, WindowEvent, ContainerEvent),
44+ * this class defines the events that indicate changes in
45+ * a component's size, position, or visibility.
46+ * <P>
47+ * This low-level event is generated by a component object (such as a
48+ * List) when the component is moved, resized, rendered invisible, or made
49+ * visible again. The event is passed to every <code>ComponentListener</code>
50+ * or <code>ComponentAdapter</code> object which registered to receive such
51+ * events using the component's <code>addComponentListener</code> method.
52+ * (<code>ComponentAdapter</code> objects implement the
53+ * <code>ComponentListener</code> interface.) Each such listener object
54+ * gets this <code>ComponentEvent</code> when the event occurs.
55+ * <p>
56+ * An unspecified behavior will be caused if the {@code id} parameter
57+ * of any particular {@code ComponentEvent} instance is not
58+ * in the range from {@code COMPONENT_FIRST} to {@code COMPONENT_LAST}.
59+ *
60+ * @see ComponentAdapter
61+ * @see ComponentListener
62+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/componentlistener.html">Tutorial: Writing a Component Listener</a>
63+ *
64+ * @author Carl Quinn
65+ * @since 1.1
66+ */
67+public class ComponentEvent extends AWTEvent {
68+
69+ /**
70+ * The first number in the range of ids used for component events.
71+ */
72+ public static final int COMPONENT_FIRST = 100;
73+
74+ /**
75+ * The last number in the range of ids used for component events.
76+ */
77+ public static final int COMPONENT_LAST = 103;
78+
79+ /**
80+ * This event indicates that the component's position changed.
81+ */
82+ public static final int COMPONENT_MOVED = COMPONENT_FIRST;
83+
84+ /**
85+ * This event indicates that the component's size changed.
86+ */
87+ public static final int COMPONENT_RESIZED = 1 + COMPONENT_FIRST;
88+
89+ /**
90+ * This event indicates that the component was made visible.
91+ */
92+ public static final int COMPONENT_SHOWN = 2 + COMPONENT_FIRST;
93+
94+ /**
95+ * This event indicates that the component was rendered invisible.
96+ */
97+ public static final int COMPONENT_HIDDEN = 3 + COMPONENT_FIRST;
98+
99+ /*
100+ * JDK 1.1 serialVersionUID
101+ */
102+ private static final long serialVersionUID = 8101406823902992965L;
103+
104+ /**
105+ * Constructs a <code>ComponentEvent</code> object.
106+ * <p> This method throws an
107+ * <code>IllegalArgumentException</code> if <code>source</code>
108+ * is <code>null</code>.
109+ *
110+ * @param source The <code>Component</code> that originated the event
111+ * @param id An integer indicating the type of event.
112+ * For information on allowable values, see
113+ * the class description for {@link ComponentEvent}
114+ * @throws IllegalArgumentException if <code>source</code> is null
115+ * @see #getComponent()
116+ * @see #getID()
117+ */
118+ public ComponentEvent(Component source, int id) {
119+ super(source, id);
120+ }
121+
122+ /**
123+ * Returns the originator of the event.
124+ *
125+ * @return the <code>Component</code> object that originated
126+ * the event, or <code>null</code> if the object is not a
127+ * <code>Component</code>.
128+ */
129+ public Component getComponent() {
130+ return (source instanceof Component) ? (Component)source : null;
131+ }
132+
133+ /**
134+ * Returns a parameter string identifying this event.
135+ * This method is useful for event-logging and for debugging.
136+ *
137+ * @return a string identifying the event and its attributes
138+ */
139+ public String paramString() {
140+ String typeStr;
141+ Rectangle b = (source !=null
142+ ? ((Component)source).getBounds()
143+ : null);
144+
145+ switch(id) {
146+ case COMPONENT_SHOWN:
147+ typeStr = "COMPONENT_SHOWN";
148+ break;
149+ case COMPONENT_HIDDEN:
150+ typeStr = "COMPONENT_HIDDEN";
151+ break;
152+ case COMPONENT_MOVED:
153+ typeStr = "COMPONENT_MOVED ("+
154+ b.x+","+b.y+" "+b.width+"x"+b.height+")";
155+ break;
156+ case COMPONENT_RESIZED:
157+ typeStr = "COMPONENT_RESIZED ("+
158+ b.x+","+b.y+" "+b.width+"x"+b.height+")";
159+ break;
160+ default:
161+ typeStr = "unknown type";
162+ }
163+ return typeStr;
164+ }
165+}
java/pkg/java/awt/event/ComponentListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/ComponentListener.java+74−0
@@ -0,0 +1,74 @@
1+/*
2+ * Copyright (c) 1996, 2006, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving component events.
32+ * The class that is interested in processing a component event
33+ * either implements this interface (and all the methods it
34+ * contains) or extends the abstract <code>ComponentAdapter</code> class
35+ * (overriding only the methods of interest).
36+ * The listener object created from that class is then registered with a
37+ * component using the component's <code>addComponentListener</code>
38+ * method. When the component's size, location, or visibility
39+ * changes, the relevant method in the listener object is invoked,
40+ * and the <code>ComponentEvent</code> is passed to it.
41+ * <P>
42+ * Component events are provided for notification purposes ONLY;
43+ * The AWT will automatically handle component moves and resizes
44+ * internally so that GUI layout works properly regardless of
45+ * whether a program registers a <code>ComponentListener</code> or not.
46+ *
47+ * @see ComponentAdapter
48+ * @see ComponentEvent
49+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/componentlistener.html">Tutorial: Writing a Component Listener</a>
50+ *
51+ * @author Carl Quinn
52+ * @since 1.1
53+ */
54+public interface ComponentListener extends EventListener {
55+ /**
56+ * Invoked when the component's size changes.
57+ */
58+ public void componentResized(ComponentEvent e);
59+
60+ /**
61+ * Invoked when the component's position changes.
62+ */
63+ public void componentMoved(ComponentEvent e);
64+
65+ /**
66+ * Invoked when the component has been made visible.
67+ */
68+ public void componentShown(ComponentEvent e);
69+
70+ /**
71+ * Invoked when the component has been made invisible.
72+ */
73+ public void componentHidden(ComponentEvent e);
74+}
java/pkg/java/awt/event/ContainerAdapter.class+0−0

Binary file not shown.

java/pkg/java/awt/event/ContainerAdapter.java+62−0
@@ -0,0 +1,62 @@
1+/*
2+ * Copyright (c) 1996, 2006, 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.event;
27+
28+/**
29+ * An abstract adapter class for receiving container events.
30+ * The methods in this class are empty. This class exists as
31+ * convenience for creating listener objects.
32+ * <P>
33+ * Extend this class to create a <code>ContainerEvent</code> listener
34+ * and override the methods for the events of interest. (If you implement the
35+ * <code>ContainerListener</code> interface, you have to define all of
36+ * the methods in it. This abstract class defines null methods for them
37+ * all, so you can only have to define methods for events you care about.)
38+ * <P>
39+ * Create a listener object using the extended class and then register it with
40+ * a component using the component's <code>addContainerListener</code>
41+ * method. When the container's contents change because a component has
42+ * been added or removed, the relevant method in the listener object is invoked,
43+ * and the <code>ContainerEvent</code> is passed to it.
44+ *
45+ * @see ContainerEvent
46+ * @see ContainerListener
47+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/containerlistener.html">Tutorial: Writing a Container Listener</a>
48+ *
49+ * @author Amy Fowler
50+ * @since 1.1
51+ */
52+public abstract class ContainerAdapter implements ContainerListener {
53+ /**
54+ * Invoked when a component has been added to the container.
55+ */
56+ public void componentAdded(ContainerEvent e) {}
57+
58+ /**
59+ * Invoked when a component has been removed from the container.
60+ */
61+ public void componentRemoved(ContainerEvent e) {}
62+}
java/pkg/java/awt/event/ContainerEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/ContainerEvent.java+159−0
@@ -0,0 +1,159 @@
1+/*
2+ * Copyright (c) 1996, 2008, 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.event;
27+
28+import java.awt.Container;
29+import java.awt.Component;
30+
31+/**
32+ * A low-level event which indicates that a container's contents
33+ * changed because a component was added or removed.
34+ * <P>
35+ * Container events are provided for notification purposes ONLY;
36+ * The AWT will automatically handle changes to the containers
37+ * contents internally so that the program works properly regardless of
38+ * whether the program is receiving these events or not.
39+ * <P>
40+ * This low-level event is generated by a container object (such as a
41+ * Panel) when a component is added to it or removed from it.
42+ * The event is passed to every <code>ContainerListener</code>
43+ * or <code>ContainerAdapter</code> object which registered to receive such
44+ * events using the component's <code>addContainerListener</code> method.
45+ * (<code>ContainerAdapter</code> objects implement the
46+ * <code>ContainerListener</code> interface.) Each such listener object
47+ * gets this <code>ContainerEvent</code> when the event occurs.
48+ * <p>
49+ * An unspecified behavior will be caused if the {@code id} parameter
50+ * of any particular {@code ContainerEvent} instance is not
51+ * in the range from {@code CONTAINER_FIRST} to {@code CONTAINER_LAST}.
52+ *
53+ * @see ContainerAdapter
54+ * @see ContainerListener
55+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/containerlistener.html">Tutorial: Writing a Container Listener</a>
56+ *
57+ * @author Tim Prinzing
58+ * @author Amy Fowler
59+ * @since 1.1
60+ */
61+public class ContainerEvent extends ComponentEvent {
62+
63+ /**
64+ * The first number in the range of ids used for container events.
65+ */
66+ public static final int CONTAINER_FIRST = 300;
67+
68+ /**
69+ * The last number in the range of ids used for container events.
70+ */
71+ public static final int CONTAINER_LAST = 301;
72+
73+ /**
74+ * This event indicates that a component was added to the container.
75+ */
76+ public static final int COMPONENT_ADDED = CONTAINER_FIRST;
77+
78+ /**
79+ * This event indicates that a component was removed from the container.
80+ */
81+ public static final int COMPONENT_REMOVED = 1 + CONTAINER_FIRST;
82+
83+ /**
84+ * The non-null component that is being added or
85+ * removed from the Container.
86+ *
87+ * @serial
88+ * @see #getChild()
89+ */
90+ Component child;
91+
92+ /*
93+ * JDK 1.1 serialVersionUID
94+ */
95+ private static final long serialVersionUID = -4114942250539772041L;
96+
97+ /**
98+ * Constructs a <code>ContainerEvent</code> object.
99+ * <p> This method throws an
100+ * <code>IllegalArgumentException</code> if <code>source</code>
101+ * is <code>null</code>.
102+ *
103+ * @param source The <code>Component</code> object (container)
104+ * that originated the event
105+ * @param id An integer indicating the type of event.
106+ * For information on allowable values, see
107+ * the class description for {@link ContainerEvent}
108+ * @param child the component that was added or removed
109+ * @throws IllegalArgumentException if <code>source</code> is null
110+ * @see #getContainer()
111+ * @see #getID()
112+ * @see #getChild()
113+ */
114+ public ContainerEvent(Component source, int id, Component child) {
115+ super(source, id);
116+ this.child = child;
117+ }
118+
119+ /**
120+ * Returns the originator of the event.
121+ *
122+ * @return the <code>Container</code> object that originated
123+ * the event, or <code>null</code> if the object is not a
124+ * <code>Container</code>.
125+ */
126+ public Container getContainer() {
127+ return (source instanceof Container) ? (Container)source : null;
128+ }
129+
130+ /**
131+ * Returns the component that was affected by the event.
132+ *
133+ * @return the Component object that was added or removed
134+ */
135+ public Component getChild() {
136+ return child;
137+ }
138+
139+ /**
140+ * Returns a parameter string identifying this event.
141+ * This method is useful for event-logging and for debugging.
142+ *
143+ * @return a string identifying the event and its attributes
144+ */
145+ public String paramString() {
146+ String typeStr;
147+ switch(id) {
148+ case COMPONENT_ADDED:
149+ typeStr = "COMPONENT_ADDED";
150+ break;
151+ case COMPONENT_REMOVED:
152+ typeStr = "COMPONENT_REMOVED";
153+ break;
154+ default:
155+ typeStr = "unknown type";
156+ }
157+ return typeStr + ",child="+child.getName();
158+ }
159+}
java/pkg/java/awt/event/ContainerListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/ContainerListener.java+66−0
@@ -0,0 +1,66 @@
1+/*
2+ * Copyright (c) 1996, 2006, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving container events.
32+ * The class that is interested in processing a container event
33+ * either implements this interface (and all the methods it
34+ * contains) or extends the abstract <code>ContainerAdapter</code> class
35+ * (overriding only the methods of interest).
36+ * The listener object created from that class is then registered with a
37+ * component using the component's <code>addContainerListener</code>
38+ * method. When the container's contents change because a component
39+ * has been added or removed, the relevant method in the listener object
40+ * is invoked, and the <code>ContainerEvent</code> is passed to it.
41+ * <P>
42+ * Container events are provided for notification purposes ONLY;
43+ * The AWT will automatically handle add and remove operations
44+ * internally so the program works properly regardless of
45+ * whether the program registers a <code>ComponentListener</code> or not.
46+ *
47+ * @see ContainerAdapter
48+ * @see ContainerEvent
49+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/containerlistener.html">Tutorial: Writing a Container Listener</a>
50+ *
51+ * @author Tim Prinzing
52+ * @author Amy Fowler
53+ * @since 1.1
54+ */
55+public interface ContainerListener extends EventListener {
56+ /**
57+ * Invoked when a component has been added to the container.
58+ */
59+ public void componentAdded(ContainerEvent e);
60+
61+ /**
62+ * Invoked when a component has been removed from the container.
63+ */
64+ public void componentRemoved(ContainerEvent e);
65+
66+}
java/pkg/java/awt/event/FocusAdapter.class+0−0

Binary file not shown.

java/pkg/java/awt/event/FocusAdapter.java+62−0
@@ -0,0 +1,62 @@
1+/*
2+ * Copyright (c) 1996, 2006, 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.event;
27+
28+/**
29+ * An abstract adapter class for receiving keyboard focus events.
30+ * The methods in this class are empty. This class exists as
31+ * convenience for creating listener objects.
32+ * <P>
33+ * Extend this class to create a <code>FocusEvent</code> listener
34+ * and override the methods for the events of interest. (If you implement the
35+ * <code>FocusListener</code> interface, you have to define all of
36+ * the methods in it. This abstract class defines null methods for them
37+ * all, so you can only have to define methods for events you care about.)
38+ * <P>
39+ * Create a listener object using the extended class and then register it with
40+ * a component using the component's <code>addFocusListener</code>
41+ * method. When the component gains or loses the keyboard focus,
42+ * the relevant method in the listener object is invoked,
43+ * and the <code>FocusEvent</code> is passed to it.
44+ *
45+ * @see FocusEvent
46+ * @see FocusListener
47+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/focuslistener.html">Tutorial: Writing a Focus Listener</a>
48+ *
49+ * @author Carl Quinn
50+ * @since 1.1
51+ */
52+public abstract class FocusAdapter implements FocusListener {
53+ /**
54+ * Invoked when a component gains the keyboard focus.
55+ */
56+ public void focusGained(FocusEvent e) {}
57+
58+ /**
59+ * Invoked when a component loses the keyboard focus.
60+ */
61+ public void focusLost(FocusEvent e) {}
62+}
java/pkg/java/awt/event/FocusEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/FocusEvent.java+249−0
@@ -0,0 +1,249 @@
1+/*
2+ * Copyright (c) 1996, 2008, 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.event;
27+
28+import java.awt.Component;
29+import sun.awt.AppContext;
30+import sun.awt.SunToolkit;
31+
32+/**
33+ * A low-level event which indicates that a Component has gained or lost the
34+ * input focus. This low-level event is generated by a Component (such as a
35+ * TextField). The event is passed to every <code>FocusListener</code> or
36+ * <code>FocusAdapter</code> object which registered to receive such events
37+ * using the Component's <code>addFocusListener</code> method. (<code>
38+ * FocusAdapter</code> objects implement the <code>FocusListener</code>
39+ * interface.) Each such listener object gets this <code>FocusEvent</code> when
40+ * the event occurs.
41+ * <p>
42+ * There are two levels of focus events: permanent and temporary. Permanent
43+ * focus change events occur when focus is directly moved from one Component to
44+ * another, such as through a call to requestFocus() or as the user uses the
45+ * TAB key to traverse Components. Temporary focus change events occur when
46+ * focus is temporarily lost for a Component as the indirect result of another
47+ * operation, such as Window deactivation or a Scrollbar drag. In this case,
48+ * the original focus state will automatically be restored once that operation
49+ * is finished, or, for the case of Window deactivation, when the Window is
50+ * reactivated. Both permanent and temporary focus events are delivered using
51+ * the FOCUS_GAINED and FOCUS_LOST event ids; the level may be distinguished in
52+ * the event using the isTemporary() method.
53+ * <p>
54+ * An unspecified behavior will be caused if the {@code id} parameter
55+ * of any particular {@code FocusEvent} instance is not
56+ * in the range from {@code FOCUS_FIRST} to {@code FOCUS_LAST}.
57+ *
58+ * @see FocusAdapter
59+ * @see FocusListener
60+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/focuslistener.html">Tutorial: Writing a Focus Listener</a>
61+ *
62+ * @author Carl Quinn
63+ * @author Amy Fowler
64+ * @since 1.1
65+ */
66+public class FocusEvent extends ComponentEvent {
67+
68+ /**
69+ * The first number in the range of ids used for focus events.
70+ */
71+ public static final int FOCUS_FIRST = 1004;
72+
73+ /**
74+ * The last number in the range of ids used for focus events.
75+ */
76+ public static final int FOCUS_LAST = 1005;
77+
78+ /**
79+ * This event indicates that the Component is now the focus owner.
80+ */
81+ public static final int FOCUS_GAINED = FOCUS_FIRST; //Event.GOT_FOCUS
82+
83+ /**
84+ * This event indicates that the Component is no longer the focus owner.
85+ */
86+ public static final int FOCUS_LOST = 1 + FOCUS_FIRST; //Event.LOST_FOCUS
87+
88+ /**
89+ * A focus event can have two different levels, permanent and temporary.
90+ * It will be set to true if some operation takes away the focus
91+ * temporarily and intends on getting it back once the event is completed.
92+ * Otherwise it will be set to false.
93+ *
94+ * @serial
95+ * @see #isTemporary
96+ */
97+ boolean temporary;
98+
99+ /**
100+ * The other Component involved in this focus change. For a FOCUS_GAINED
101+ * event, this is the Component that lost focus. For a FOCUS_LOST event,
102+ * this is the Component that gained focus. If this focus change occurs
103+ * with a native application, a Java application in a different VM, or with
104+ * no other Component, then the opposite Component is null.
105+ *
106+ * @see #getOppositeComponent
107+ * @since 1.4
108+ */
109+ transient Component opposite;
110+
111+ /*
112+ * JDK 1.1 serialVersionUID
113+ */
114+ private static final long serialVersionUID = 523753786457416396L;
115+
116+ /**
117+ * Constructs a <code>FocusEvent</code> object with the
118+ * specified temporary state and opposite <code>Component</code>.
119+ * The opposite <code>Component</code> is the other
120+ * <code>Component</code> involved in this focus change.
121+ * For a <code>FOCUS_GAINED</code> event, this is the
122+ * <code>Component</code> that lost focus. For a
123+ * <code>FOCUS_LOST</code> event, this is the <code>Component</code>
124+ * that gained focus. If this focus change occurs with a native
125+ * application, with a Java application in a different VM,
126+ * or with no other <code>Component</code>, then the opposite
127+ * <code>Component</code> is <code>null</code>.
128+ * <p> This method throws an
129+ * <code>IllegalArgumentException</code> if <code>source</code>
130+ * is <code>null</code>.
131+ *
132+ * @param source The <code>Component</code> that originated the event
133+ * @param id An integer indicating the type of event.
134+ * For information on allowable values, see
135+ * the class description for {@link FocusEvent}
136+ * @param temporary Equals <code>true</code> if the focus change is temporary;
137+ * <code>false</code> otherwise
138+ * @param opposite The other Component involved in the focus change,
139+ * or <code>null</code>
140+ * @throws IllegalArgumentException if <code>source</code> equals {@code null}
141+ * @see #getSource()
142+ * @see #getID()
143+ * @see #isTemporary()
144+ * @see #getOppositeComponent()
145+ * @since 1.4
146+ */
147+ public FocusEvent(Component source, int id, boolean temporary,
148+ Component opposite) {
149+ super(source, id);
150+ this.temporary = temporary;
151+ this.opposite = opposite;
152+ }
153+
154+ /**
155+ * Constructs a <code>FocusEvent</code> object and identifies
156+ * whether or not the change is temporary.
157+ * <p> This method throws an
158+ * <code>IllegalArgumentException</code> if <code>source</code>
159+ * is <code>null</code>.
160+ *
161+ * @param source The <code>Component</code> that originated the event
162+ * @param id An integer indicating the type of event.
163+ * For information on allowable values, see
164+ * the class description for {@link FocusEvent}
165+ * @param temporary Equals <code>true</code> if the focus change is temporary;
166+ * <code>false</code> otherwise
167+ * @throws IllegalArgumentException if <code>source</code> equals {@code null}
168+ * @see #getSource()
169+ * @see #getID()
170+ * @see #isTemporary()
171+ */
172+ public FocusEvent(Component source, int id, boolean temporary) {
173+ this(source, id, temporary, null);
174+ }
175+
176+ /**
177+ * Constructs a <code>FocusEvent</code> object and identifies it
178+ * as a permanent change in focus.
179+ * <p> This method throws an
180+ * <code>IllegalArgumentException</code> if <code>source</code>
181+ * is <code>null</code>.
182+ *
183+ * @param source The <code>Component</code> that originated the event
184+ * @param id An integer indicating the type of event.
185+ * For information on allowable values, see
186+ * the class description for {@link FocusEvent}
187+ * @throws IllegalArgumentException if <code>source</code> equals {@code null}
188+ * @see #getSource()
189+ * @see #getID()
190+ */
191+ public FocusEvent(Component source, int id) {
192+ this(source, id, false);
193+ }
194+
195+ /**
196+ * Identifies the focus change event as temporary or permanent.
197+ *
198+ * @return <code>true</code> if the focus change is temporary;
199+ * <code>false</code> otherwise
200+ */
201+ public boolean isTemporary() {
202+ return temporary;
203+ }
204+
205+ /**
206+ * Returns the other Component involved in this focus change. For a
207+ * FOCUS_GAINED event, this is the Component that lost focus. For a
208+ * FOCUS_LOST event, this is the Component that gained focus. If this
209+ * focus change occurs with a native application, with a Java application
210+ * in a different VM or context, or with no other Component, then null is
211+ * returned.
212+ *
213+ * @return the other Component involved in the focus change, or null
214+ * @since 1.4
215+ */
216+ public Component getOppositeComponent() {
217+ if (opposite == null) {
218+ return null;
219+ }
220+
221+ return (SunToolkit.targetToAppContext(opposite) ==
222+ AppContext.getAppContext())
223+ ? opposite
224+ : null;
225+ }
226+
227+ /**
228+ * Returns a parameter string identifying this event.
229+ * This method is useful for event-logging and for debugging.
230+ *
231+ * @return a string identifying the event and its attributes
232+ */
233+ public String paramString() {
234+ String typeStr;
235+ switch(id) {
236+ case FOCUS_GAINED:
237+ typeStr = "FOCUS_GAINED";
238+ break;
239+ case FOCUS_LOST:
240+ typeStr = "FOCUS_LOST";
241+ break;
242+ default:
243+ typeStr = "unknown type";
244+ }
245+ return typeStr + (temporary ? ",temporary" : ",permanent") +
246+ ",opposite=" + getOppositeComponent();
247+ }
248+
249+}
java/pkg/java/awt/event/FocusListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/FocusListener.java+61−0
@@ -0,0 +1,61 @@
1+/*
2+ * Copyright (c) 1996, 2006, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving keyboard focus events on
32+ * a component.
33+ * The class that is interested in processing a focus event
34+ * either implements this interface (and all the methods it
35+ * contains) or extends the abstract <code>FocusAdapter</code> class
36+ * (overriding only the methods of interest).
37+ * The listener object created from that class is then registered with a
38+ * component using the component's <code>addFocusListener</code>
39+ * method. When the component gains or loses the keyboard focus,
40+ * the relevant method in the listener object
41+ * is invoked, and the <code>FocusEvent</code> is passed to it.
42+ *
43+ * @see FocusAdapter
44+ * @see FocusEvent
45+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/focuslistener.html">Tutorial: Writing a Focus Listener</a>
46+ *
47+ * @author Carl Quinn
48+ * @since 1.1
49+ */
50+public interface FocusListener extends EventListener {
51+
52+ /**
53+ * Invoked when a component gains the keyboard focus.
54+ */
55+ public void focusGained(FocusEvent e);
56+
57+ /**
58+ * Invoked when a component loses the keyboard focus.
59+ */
60+ public void focusLost(FocusEvent e);
61+}
java/pkg/java/awt/event/HierarchyBoundsAdapter.class+0−0

Binary file not shown.

java/pkg/java/awt/event/HierarchyBoundsAdapter.java+61−0
@@ -0,0 +1,61 @@
1+/*
2+ * Copyright (c) 1999, 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.event;
27+
28+/**
29+ * An abstract adapter class for receiving ancestor moved and resized events.
30+ * The methods in this class are empty. This class exists as a
31+ * convenience for creating listener objects.
32+ * <p>
33+ * Extend this class and override the method for the event of interest. (If
34+ * you implement the <code>HierarchyBoundsListener</code> interface, you have
35+ * to define both methods in it. This abstract class defines null methods for
36+ * them both, so you only have to define the method for the event you care
37+ * about.)
38+ * <p>
39+ * Create a listener object using your class and then register it with a
40+ * Component using the Component's <code>addHierarchyBoundsListener</code>
41+ * method. When the hierarchy to which the Component belongs changes by
42+ * resize or movement of an ancestor, the relevant method in the listener
43+ * object is invoked, and the <code>HierarchyEvent</code> is passed to it.
44+ *
45+ * @author David Mendenhall
46+ * @see HierarchyBoundsListener
47+ * @see HierarchyEvent
48+ * @since 1.3
49+ */
50+public abstract class HierarchyBoundsAdapter implements HierarchyBoundsListener
51+{
52+ /**
53+ * Called when an ancestor of the source is moved.
54+ */
55+ public void ancestorMoved(HierarchyEvent e) {}
56+
57+ /**
58+ * Called when an ancestor of the source is resized.
59+ */
60+ public void ancestorResized(HierarchyEvent e) {}
61+}
java/pkg/java/awt/event/HierarchyBoundsListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/HierarchyBoundsListener.java+62−0
@@ -0,0 +1,62 @@
1+/*
2+ * Copyright (c) 1999, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving ancestor moved and resized events.
32+ * The class that is interested in processing these events either implements
33+ * this interface (and all the methods it contains) or extends the abstract
34+ * <code>HierarchyBoundsAdapter</code> class (overriding only the method of
35+ * interest).
36+ * The listener object created from that class is then registered with a
37+ * Component using the Component's <code>addHierarchyBoundsListener</code>
38+ * method. When the hierarchy to which the Component belongs changes by
39+ * the resizing or movement of an ancestor, the relevant method in the listener
40+ * object is invoked, and the <code>HierarchyEvent</code> is passed to it.
41+ * <p>
42+ * Hierarchy events are provided for notification purposes ONLY;
43+ * The AWT will automatically handle changes to the hierarchy internally so
44+ * that GUI layout works properly regardless of whether a
45+ * program registers an <code>HierarchyBoundsListener</code> or not.
46+ *
47+ * @author David Mendenhall
48+ * @see HierarchyBoundsAdapter
49+ * @see HierarchyEvent
50+ * @since 1.3
51+ */
52+public interface HierarchyBoundsListener extends EventListener {
53+ /**
54+ * Called when an ancestor of the source is moved.
55+ */
56+ public void ancestorMoved(HierarchyEvent e);
57+
58+ /**
59+ * Called when an ancestor of the source is resized.
60+ */
61+ public void ancestorResized(HierarchyEvent e);
62+}
java/pkg/java/awt/event/HierarchyEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/HierarchyEvent.java+337−0
@@ -0,0 +1,337 @@
1+/*
2+ * Copyright (c) 1999, 2008, 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.event;
27+
28+import java.awt.AWTEvent;
29+import java.awt.Component;
30+import java.awt.Container;
31+
32+/**
33+ * An event which indicates a change to the <code>Component</code>
34+ * hierarchy to which <code>Component</code> belongs.
35+ * <ul>
36+ * <li>Hierarchy Change Events (HierarchyListener)
37+ * <ul>
38+ * <li> addition of an ancestor
39+ * <li> removal of an ancestor
40+ * <li> hierarchy made displayable
41+ * <li> hierarchy made undisplayable
42+ * <li> hierarchy shown on the screen (both visible and displayable)
43+ * <li> hierarchy hidden on the screen (either invisible or undisplayable)
44+ * </ul>
45+ * <li>Ancestor Reshape Events (HierarchyBoundsListener)
46+ * <ul>
47+ * <li> an ancestor was resized
48+ * <li> an ancestor was moved
49+ * </ul>
50+ * </ul>
51+ * <p>
52+ * Hierarchy events are provided for notification purposes ONLY.
53+ * The AWT will automatically handle changes to the hierarchy internally so
54+ * that GUI layout and displayability works properly regardless of whether a
55+ * program is receiving these events or not.
56+ * <p>
57+ * This event is generated by a Container object (such as a Panel) when the
58+ * Container is added, removed, moved, or resized, and passed down the
59+ * hierarchy. It is also generated by a Component object when that object's
60+ * <code>addNotify</code>, <code>removeNotify</code>, <code>show</code>, or
61+ * <code>hide</code> method is called. The {@code ANCESTOR_MOVED} and
62+ * {@code ANCESTOR_RESIZED}
63+ * events are dispatched to every <code>HierarchyBoundsListener</code> or
64+ * <code>HierarchyBoundsAdapter</code> object which registered to receive
65+ * such events using the Component's <code>addHierarchyBoundsListener</code>
66+ * method. (<code>HierarchyBoundsAdapter</code> objects implement the <code>
67+ * HierarchyBoundsListener</code> interface.) The {@code HIERARCHY_CHANGED} events are
68+ * dispatched to every <code>HierarchyListener</code> object which registered
69+ * to receive such events using the Component's <code>addHierarchyListener
70+ * </code> method. Each such listener object gets this <code>HierarchyEvent
71+ * </code> when the event occurs.
72+ * <p>
73+ * An unspecified behavior will be caused if the {@code id} parameter
74+ * of any particular {@code HierarchyEvent} instance is not
75+ * in the range from {@code HIERARCHY_FIRST} to {@code HIERARCHY_LAST}.
76+ * <br>
77+ * The {@code changeFlags} parameter of any {@code HierarchyEvent} instance takes one of the following
78+ * values:
79+ * <ul>
80+ * <li> {@code HierarchyEvent.PARENT_CHANGED}
81+ * <li> {@code HierarchyEvent.DISPLAYABILITY_CHANGED}
82+ * <li> {@code HierarchyEvent.SHOWING_CHANGED}
83+ * </ul>
84+ * Assigning the value different from listed above will cause unspecified behavior.
85+ *
86+ * @author David Mendenhall
87+ * @see HierarchyListener
88+ * @see HierarchyBoundsAdapter
89+ * @see HierarchyBoundsListener
90+ * @since 1.3
91+ */
92+public class HierarchyEvent extends AWTEvent {
93+ /*
94+ * serialVersionUID
95+ */
96+ private static final long serialVersionUID = -5337576970038043990L;
97+
98+ /**
99+ * Marks the first integer id for the range of hierarchy event ids.
100+ */
101+ public static final int HIERARCHY_FIRST = 1400; // 1300 used by sun.awt.windows.ModalityEvent
102+
103+ /**
104+ * The event id indicating that modification was made to the
105+ * entire hierarchy tree.
106+ */
107+ public static final int HIERARCHY_CHANGED = HIERARCHY_FIRST;
108+
109+ /**
110+ * The event id indicating an ancestor-Container was moved.
111+ */
112+ public static final int ANCESTOR_MOVED = 1 + HIERARCHY_FIRST;
113+
114+ /**
115+ * The event id indicating an ancestor-Container was resized.
116+ */
117+ public static final int ANCESTOR_RESIZED = 2 + HIERARCHY_FIRST;
118+
119+ /**
120+ * Marks the last integer id for the range of ancestor event ids.
121+ */
122+ public static final int HIERARCHY_LAST = ANCESTOR_RESIZED;
123+
124+ /**
125+ * A change flag indicates that the <code>HIERARCHY_CHANGED</code> event
126+ * was generated by a reparenting operation.
127+ */
128+ public static final int PARENT_CHANGED = 0x1;
129+
130+ /**
131+ * A change flag indicates that the <code>HIERARCHY_CHANGED</code> event
132+ * was generated due to the changing of the hierarchy displayability.
133+ * To discern the
134+ * current displayability of the hierarchy, call the
135+ * <code>Component.isDisplayable</code> method. Displayability changes occur
136+ * in response to explicit or implicit calls of the
137+ * <code>Component.addNotify</code> and
138+ * <code>Component.removeNotify</code> methods.
139+ *
140+ * @see java.awt.Component#isDisplayable()
141+ * @see java.awt.Component#addNotify()
142+ * @see java.awt.Component#removeNotify()
143+ */
144+ public static final int DISPLAYABILITY_CHANGED = 0x2;
145+
146+ /**
147+ * A change flag indicates that the <code>HIERARCHY_CHANGED</code> event
148+ * was generated due to the changing of the hierarchy showing state.
149+ * To discern the
150+ * current showing state of the hierarchy, call the
151+ * <code>Component.isShowing</code> method. Showing state changes occur
152+ * when either the displayability or visibility of the
153+ * hierarchy occurs. Visibility changes occur in response to explicit
154+ * or implicit calls of the <code>Component.show</code> and
155+ * <code>Component.hide</code> methods.
156+ *
157+ * @see java.awt.Component#isShowing()
158+ * @see java.awt.Component#addNotify()
159+ * @see java.awt.Component#removeNotify()
160+ * @see java.awt.Component#show()
161+ * @see java.awt.Component#hide()
162+ */
163+ public static final int SHOWING_CHANGED = 0x4;
164+
165+ Component changed;
166+ Container changedParent;
167+ long changeFlags;
168+
169+ /**
170+ * Constructs an <code>HierarchyEvent</code> object to identify a
171+ * change in the <code>Component</code> hierarchy.
172+ * <p>This method throws an
173+ * <code>IllegalArgumentException</code> if <code>source</code>
174+ * is <code>null</code>.
175+ *
176+ * @param source The <code>Component</code> object that
177+ * originated the event
178+ * @param id An integer indicating the type of event.
179+ * For information on allowable values, see
180+ * the class description for {@link HierarchyEvent}
181+ * @param changed The <code>Component</code> at the top of
182+ * the hierarchy which was changed
183+ * @param changedParent The parent of the <code>changed</code> component.
184+ * This
185+ * may be the parent before or after the
186+ * change, depending on the type of change
187+ * @throws IllegalArgumentException if <code>source</code> is {@code null}
188+ * @see #getSource()
189+ * @see #getID()
190+ * @see #getChanged()
191+ * @see #getChangedParent()
192+ */
193+ public HierarchyEvent(Component source, int id, Component changed,
194+ Container changedParent) {
195+ super(source, id);
196+ this.changed = changed;
197+ this.changedParent = changedParent;
198+ }
199+
200+ /**
201+ * Constructs an <code>HierarchyEvent</code> object to identify
202+ * a change in the <code>Component</code> hierarchy.
203+ * <p> This method throws an
204+ * <code>IllegalArgumentException</code> if <code>source</code>
205+ * is <code>null</code>.
206+ *
207+ * @param source The <code>Component</code> object that
208+ * originated the event
209+ * @param id An integer indicating the type of event.
210+ * For information on allowable values, see
211+ * the class description for {@link HierarchyEvent}
212+ * @param changed The <code>Component</code> at the top
213+ * of the hierarchy which was changed
214+ * @param changedParent The parent of the <code>changed</code> component.
215+ * This
216+ * may be the parent before or after the
217+ * change, depending on the type of change
218+ * @param changeFlags A bitmask which indicates the type(s) of
219+ * the <code>HIERARCHY_CHANGED</code> events
220+ * represented in this event object.
221+ * For information on allowable values, see
222+ * the class description for {@link HierarchyEvent}
223+ * @throws IllegalArgumentException if <code>source</code> is null
224+ * @see #getSource()
225+ * @see #getID()
226+ * @see #getChanged()
227+ * @see #getChangedParent()
228+ * @see #getChangeFlags()
229+ */
230+ public HierarchyEvent(Component source, int id, Component changed,
231+ Container changedParent, long changeFlags) {
232+ super(source, id);
233+ this.changed = changed;
234+ this.changedParent = changedParent;
235+ this.changeFlags = changeFlags;
236+ }
237+
238+ /**
239+ * Returns the originator of the event.
240+ *
241+ * @return the <code>Component</code> object that originated
242+ * the event, or <code>null</code> if the object is not a
243+ * <code>Component</code>.
244+ */
245+ public Component getComponent() {
246+ return (source instanceof Component) ? (Component)source : null;
247+ }
248+
249+ /**
250+ * Returns the Component at the top of the hierarchy which was
251+ * changed.
252+ *
253+ * @return the changed Component
254+ */
255+ public Component getChanged() {
256+ return changed;
257+ }
258+
259+ /**
260+ * Returns the parent of the Component returned by <code>
261+ * getChanged()</code>. For a HIERARCHY_CHANGED event where the
262+ * change was of type PARENT_CHANGED via a call to <code>
263+ * Container.add</code>, the parent returned is the parent
264+ * after the add operation. For a HIERARCHY_CHANGED event where
265+ * the change was of type PARENT_CHANGED via a call to <code>
266+ * Container.remove</code>, the parent returned is the parent
267+ * before the remove operation. For all other events and types,
268+ * the parent returned is the parent during the operation.
269+ *
270+ * @return the parent of the changed Component
271+ */
272+ public Container getChangedParent() {
273+ return changedParent;
274+ }
275+
276+ /**
277+ * Returns a bitmask which indicates the type(s) of
278+ * HIERARCHY_CHANGED events represented in this event object.
279+ * The bits have been bitwise-ored together.
280+ *
281+ * @return the bitmask, or 0 if this is not an HIERARCHY_CHANGED
282+ * event
283+ */
284+ public long getChangeFlags() {
285+ return changeFlags;
286+ }
287+
288+ /**
289+ * Returns a parameter string identifying this event.
290+ * This method is useful for event-logging and for debugging.
291+ *
292+ * @return a string identifying the event and its attributes
293+ */
294+ public String paramString() {
295+ String typeStr;
296+ switch(id) {
297+ case ANCESTOR_MOVED:
298+ typeStr = "ANCESTOR_MOVED ("+changed+","+changedParent+")";
299+ break;
300+ case ANCESTOR_RESIZED:
301+ typeStr = "ANCESTOR_RESIZED ("+changed+","+changedParent+")";
302+ break;
303+ case HIERARCHY_CHANGED: {
304+ typeStr = "HIERARCHY_CHANGED (";
305+ boolean first = true;
306+ if ((changeFlags & PARENT_CHANGED) != 0) {
307+ first = false;
308+ typeStr += "PARENT_CHANGED";
309+ }
310+ if ((changeFlags & DISPLAYABILITY_CHANGED) != 0) {
311+ if (first) {
312+ first = false;
313+ } else {
314+ typeStr += ",";
315+ }
316+ typeStr += "DISPLAYABILITY_CHANGED";
317+ }
318+ if ((changeFlags & SHOWING_CHANGED) != 0) {
319+ if (first) {
320+ first = false;
321+ } else {
322+ typeStr += ",";
323+ }
324+ typeStr += "SHOWING_CHANGED";
325+ }
326+ if (!first) {
327+ typeStr += ",";
328+ }
329+ typeStr += changed + "," + changedParent + ")";
330+ break;
331+ }
332+ default:
333+ typeStr = "unknown type";
334+ }
335+ return typeStr;
336+ }
337+}
java/pkg/java/awt/event/HierarchyListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/HierarchyListener.java+57−0
@@ -0,0 +1,57 @@
1+/*
2+ * Copyright (c) 1999, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving hierarchy changed events.
32+ * The class that is interested in processing a hierarchy changed event
33+ * should implement this interface.
34+ * The listener object created from that class is then registered with a
35+ * Component using the Component's <code>addHierarchyListener</code>
36+ * method. When the hierarchy to which the Component belongs changes, the
37+ * <code>hierarchyChanged</code> method in the listener object is invoked,
38+ * and the <code>HierarchyEvent</code> is passed to it.
39+ * <p>
40+ * Hierarchy events are provided for notification purposes ONLY;
41+ * The AWT will automatically handle changes to the hierarchy internally so
42+ * that GUI layout, displayability, and visibility work properly regardless
43+ * of whether a program registers a <code>HierarchyListener</code> or not.
44+ *
45+ * @author David Mendenhall
46+ * @see HierarchyEvent
47+ * @since 1.3
48+ */
49+public interface HierarchyListener extends EventListener {
50+ /**
51+ * Called when the hierarchy has been changed. To discern the actual
52+ * type of change, call <code>HierarchyEvent.getChangeFlags()</code>.
53+ *
54+ * @see HierarchyEvent#getChangeFlags()
55+ */
56+ public void hierarchyChanged(HierarchyEvent e);
57+}
java/pkg/java/awt/event/InputEvent$1.class+0−0

Binary file not shown.

java/pkg/java/awt/event/InputEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/InputEvent.java+527−0
@@ -0,0 +1,527 @@
1+/*
2+ * Copyright (c) 1996, 2010, 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.event;
27+
28+import java.awt.Event;
29+import java.awt.Component;
30+import java.awt.GraphicsEnvironment;
31+import java.awt.Toolkit;
32+import java.util.Arrays;
33+
34+import sun.awt.AWTAccessor;
35+import sun.util.logging.PlatformLogger;
36+
37+/**
38+ * The root event class for all component-level input events.
39+ *
40+ * Input events are delivered to listeners before they are
41+ * processed normally by the source where they originated.
42+ * This allows listeners and component subclasses to "consume"
43+ * the event so that the source will not process them in their
44+ * default manner. For example, consuming mousePressed events
45+ * on a Button component will prevent the Button from being
46+ * activated.
47+ *
48+ * @author Carl Quinn
49+ *
50+ * @see KeyEvent
51+ * @see KeyAdapter
52+ * @see MouseEvent
53+ * @see MouseAdapter
54+ * @see MouseMotionAdapter
55+ *
56+ * @since 1.1
57+ */
58+public abstract class InputEvent extends ComponentEvent {
59+
60+ private static final PlatformLogger logger = PlatformLogger.getLogger("java.awt.event.InputEvent");
61+
62+ /**
63+ * The Shift key modifier constant.
64+ * It is recommended that SHIFT_DOWN_MASK be used instead.
65+ */
66+ public static final int SHIFT_MASK = Event.SHIFT_MASK;
67+
68+ /**
69+ * The Control key modifier constant.
70+ * It is recommended that CTRL_DOWN_MASK be used instead.
71+ */
72+ public static final int CTRL_MASK = Event.CTRL_MASK;
73+
74+ /**
75+ * The Meta key modifier constant.
76+ * It is recommended that META_DOWN_MASK be used instead.
77+ */
78+ public static final int META_MASK = Event.META_MASK;
79+
80+ /**
81+ * The Alt key modifier constant.
82+ * It is recommended that ALT_DOWN_MASK be used instead.
83+ */
84+ public static final int ALT_MASK = Event.ALT_MASK;
85+
86+ /**
87+ * The AltGraph key modifier constant.
88+ */
89+ public static final int ALT_GRAPH_MASK = 1 << 5;
90+
91+ /**
92+ * The Mouse Button1 modifier constant.
93+ * It is recommended that BUTTON1_DOWN_MASK be used instead.
94+ */
95+ public static final int BUTTON1_MASK = 1 << 4;
96+
97+ /**
98+ * The Mouse Button2 modifier constant.
99+ * It is recommended that BUTTON2_DOWN_MASK be used instead.
100+ * Note that BUTTON2_MASK has the same value as ALT_MASK.
101+ */
102+ public static final int BUTTON2_MASK = Event.ALT_MASK;
103+
104+ /**
105+ * The Mouse Button3 modifier constant.
106+ * It is recommended that BUTTON3_DOWN_MASK be used instead.
107+ * Note that BUTTON3_MASK has the same value as META_MASK.
108+ */
109+ public static final int BUTTON3_MASK = Event.META_MASK;
110+
111+ /**
112+ * The Shift key extended modifier constant.
113+ * @since 1.4
114+ */
115+ public static final int SHIFT_DOWN_MASK = 1 << 6;
116+
117+ /**
118+ * The Control key extended modifier constant.
119+ * @since 1.4
120+ */
121+ public static final int CTRL_DOWN_MASK = 1 << 7;
122+
123+ /**
124+ * The Meta key extended modifier constant.
125+ * @since 1.4
126+ */
127+ public static final int META_DOWN_MASK = 1 << 8;
128+
129+ /**
130+ * The Alt key extended modifier constant.
131+ * @since 1.4
132+ */
133+ public static final int ALT_DOWN_MASK = 1 << 9;
134+
135+ /**
136+ * The Mouse Button1 extended modifier constant.
137+ * @since 1.4
138+ */
139+ public static final int BUTTON1_DOWN_MASK = 1 << 10;
140+
141+ /**
142+ * The Mouse Button2 extended modifier constant.
143+ * @since 1.4
144+ */
145+ public static final int BUTTON2_DOWN_MASK = 1 << 11;
146+
147+ /**
148+ * The Mouse Button3 extended modifier constant.
149+ * @since 1.4
150+ */
151+ public static final int BUTTON3_DOWN_MASK = 1 << 12;
152+
153+ /**
154+ * The AltGraph key extended modifier constant.
155+ * @since 1.4
156+ */
157+ public static final int ALT_GRAPH_DOWN_MASK = 1 << 13;
158+
159+ /**
160+ * An array of extended modifiers for additional buttons.
161+ * @see getButtonDownMasks
162+ * There are twenty buttons fit into 4byte space.
163+ * one more bit is reserved for FIRST_HIGH_BIT.
164+ * @since 7.0
165+ */
166+ private static final int [] BUTTON_DOWN_MASK = new int [] { BUTTON1_DOWN_MASK,
167+ BUTTON2_DOWN_MASK,
168+ BUTTON3_DOWN_MASK,
169+ 1<<14, //4th phisical button (this is not a wheel!)
170+ 1<<15, //(this is not a wheel!)
171+ 1<<16,
172+ 1<<17,
173+ 1<<18,
174+ 1<<19,
175+ 1<<20,
176+ 1<<21,
177+ 1<<22,
178+ 1<<23,
179+ 1<<24,
180+ 1<<25,
181+ 1<<26,
182+ 1<<27,
183+ 1<<28,
184+ 1<<29,
185+ 1<<30};
186+
187+ /**
188+ * A method to access an array of extended modifiers for additional buttons.
189+ * @since 7.0
190+ */
191+ private static int [] getButtonDownMasks(){
192+ return Arrays.copyOf(BUTTON_DOWN_MASK, BUTTON_DOWN_MASK.length);
193+ }
194+
195+
196+ /**
197+ * A method to obtain a mask for any existing mouse button.
198+ * The returned mask may be used for different purposes. Following are some of them:
199+ * <ul>
200+ * <li> {@link java.awt.Robot#mousePress(int) mousePress(buttons)} and
201+ * {@link java.awt.Robot#mouseRelease(int) mouseRelease(buttons)}
202+ * <li> as a {@code modifiers} parameter when creating a new {@link MouseEvent} instance
203+ * <li> to check {@link MouseEvent#getModifiersEx() modifiersEx} of existing {@code MouseEvent}
204+ * </ul>
205+ * @param button is a number to represent a button starting from 1.
206+ * For example,
207+ * <pre>
208+ * int button = InputEvent.getMaskForButton(1);
209+ * </pre>
210+ * will have the same meaning as
211+ * <pre>
212+ * int button = InputEvent.getMaskForButton(MouseEvent.BUTTON1);
213+ * </pre>
214+ * because {@link MouseEvent#BUTTON1 MouseEvent.BUTTON1} equals to 1.
215+ * If a mouse has three enabled buttons(see {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()})
216+ * then the values from the left column passed into the method will return
217+ * corresponding values from the right column:
218+ * <PRE>
219+ * <b>button </b> <b>returned mask</b>
220+ * {@link MouseEvent#BUTTON1 BUTTON1} {@link MouseEvent#BUTTON1_DOWN_MASK BUTTON1_DOWN_MASK}
221+ * {@link MouseEvent#BUTTON2 BUTTON2} {@link MouseEvent#BUTTON2_DOWN_MASK BUTTON2_DOWN_MASK}
222+ * {@link MouseEvent#BUTTON3 BUTTON3} {@link MouseEvent#BUTTON3_DOWN_MASK BUTTON3_DOWN_MASK}
223+ * </PRE>
224+ * If a mouse has more than three enabled buttons then more values
225+ * are admissible (4, 5, etc.). There is no assigned constants for these extended buttons.
226+ * The button masks for the extra buttons returned by this method have no assigned names like the
227+ * first three button masks.
228+ * <p>
229+ * This method has the following implementation restriction.
230+ * It returns masks for a limited number of buttons only. The maximum number is
231+ * implementation dependent and may vary.
232+ * This limit is defined by the relevant number
233+ * of buttons that may hypothetically exist on the mouse but it is greater than the
234+ * {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}.
235+ * <p>
236+ * @throws IllegalArgumentException if {@code button} is less than zero or greater than the number
237+ * of button masks reserved for buttons
238+ * @since 7.0
239+ * @see java.awt.MouseInfo#getNumberOfButtons()
240+ * @see Toolkit#areExtraMouseButtonsEnabled()
241+ * @see MouseEvent#getModifiers()
242+ * @see MouseEvent#getModifiersEx()
243+ */
244+ public static int getMaskForButton(int button) {
245+ if (button <= 0 || button > BUTTON_DOWN_MASK.length) {
246+ throw new IllegalArgumentException("button doesn\'t exist " + button);
247+ }
248+ return BUTTON_DOWN_MASK[button - 1];
249+ }
250+
251+ // the constant below MUST be updated if any extra modifier
252+ // bits are to be added!
253+ // in fact, it is undesirable to add modifier bits
254+ // to the same field as this may break applications
255+ // see bug# 5066958
256+ static final int FIRST_HIGH_BIT = 1 << 31;
257+
258+ static final int JDK_1_3_MODIFIERS = SHIFT_DOWN_MASK - 1;
259+ static final int HIGH_MODIFIERS = ~( FIRST_HIGH_BIT - 1 );
260+
261+ /**
262+ * The input event's Time stamp in UTC format. The time stamp
263+ * indicates when the input event was created.
264+ *
265+ * @serial
266+ * @see #getWhen()
267+ */
268+ long when;
269+
270+ /**
271+ * The state of the modifier mask at the time the input
272+ * event was fired.
273+ *
274+ * @serial
275+ * @see #getModifiers()
276+ * @see #getModifiersEx()
277+ * @see java.awt.event.KeyEvent
278+ * @see java.awt.event.MouseEvent
279+ */
280+ int modifiers;
281+
282+ /*
283+ * A flag that indicates that this instance can be used to access
284+ * the system clipboard.
285+ */
286+ private transient boolean canAccessSystemClipboard;
287+
288+ static {
289+ /* ensure that the necessary native libraries are loaded */
290+ NativeLibLoader.loadLibraries();
291+ if (!GraphicsEnvironment.isHeadless()) {
292+ initIDs();
293+ }
294+ AWTAccessor.setInputEventAccessor(
295+ new AWTAccessor.InputEventAccessor() {
296+ public int[] getButtonDownMasks() {
297+ return InputEvent.getButtonDownMasks();
298+ }
299+ });
300+ }
301+
302+ /**
303+ * Initialize JNI field and method IDs for fields that may be
304+ accessed from C.
305+ */
306+ private static native void initIDs();
307+
308+ /**
309+ * Constructs an InputEvent object with the specified source component,
310+ * modifiers, and type.
311+ * <p> This method throws an
312+ * <code>IllegalArgumentException</code> if <code>source</code>
313+ * is <code>null</code>.
314+ *
315+ * @param source the object where the event originated
316+ * @param id the integer that identifies the event type.
317+ * It is allowed to pass as parameter any value that
318+ * allowed for some subclass of {@code InputEvent} class.
319+ * Passing in the value different from those values result
320+ * in unspecified behavior
321+ * @param when a long int that gives the time the event occurred.
322+ * Passing negative or zero value
323+ * is not recommended
324+ * @param modifiers the modifier keys down during event (e.g. shift, ctrl,
325+ * alt, meta)
326+ * Passing negative parameter is not recommended.
327+ * Zero value means no modifiers.
328+ * Either extended _DOWN_MASK or old _MASK modifiers
329+ * should be used, but both models should not be mixed
330+ * in one event. Use of the extended modifiers is
331+ * preferred
332+ * @throws IllegalArgumentException if <code>source</code> is null
333+ * @see #getSource()
334+ * @see #getID()
335+ * @see #getWhen()
336+ * @see #getModifiers()
337+ */
338+ InputEvent(Component source, int id, long when, int modifiers) {
339+ super(source, id);
340+ this.when = when;
341+ this.modifiers = modifiers;
342+ canAccessSystemClipboard = canAccessSystemClipboard();
343+ }
344+
345+ private boolean canAccessSystemClipboard() {
346+ boolean b = false;
347+
348+ if (!GraphicsEnvironment.isHeadless()) {
349+ SecurityManager sm = System.getSecurityManager();
350+ if (sm != null) {
351+ try {
352+ sm.checkSystemClipboardAccess();
353+ b = true;
354+ } catch (SecurityException se) {
355+ if (logger.isLoggable(PlatformLogger.FINE)) {
356+ logger.fine("InputEvent.canAccessSystemClipboard() got SecurityException ", se);
357+ }
358+ }
359+ } else {
360+ b = true;
361+ }
362+ }
363+
364+ return b;
365+ }
366+
367+ /**
368+ * Returns whether or not the Shift modifier is down on this event.
369+ */
370+ public boolean isShiftDown() {
371+ return (modifiers & SHIFT_MASK) != 0;
372+ }
373+
374+ /**
375+ * Returns whether or not the Control modifier is down on this event.
376+ */
377+ public boolean isControlDown() {
378+ return (modifiers & CTRL_MASK) != 0;
379+ }
380+
381+ /**
382+ * Returns whether or not the Meta modifier is down on this event.
383+ */
384+ public boolean isMetaDown() {
385+ return (modifiers & META_MASK) != 0;
386+ }
387+
388+ /**
389+ * Returns whether or not the Alt modifier is down on this event.
390+ */
391+ public boolean isAltDown() {
392+ return (modifiers & ALT_MASK) != 0;
393+ }
394+
395+ /**
396+ * Returns whether or not the AltGraph modifier is down on this event.
397+ */
398+ public boolean isAltGraphDown() {
399+ return (modifiers & ALT_GRAPH_MASK) != 0;
400+ }
401+
402+ /**
403+ * Returns the difference in milliseconds between the timestamp of when this event occurred and
404+ * midnight, January 1, 1970 UTC.
405+ */
406+ public long getWhen() {
407+ return when;
408+ }
409+
410+ /**
411+ * Returns the modifier mask for this event.
412+ */
413+ public int getModifiers() {
414+ return modifiers & (JDK_1_3_MODIFIERS | HIGH_MODIFIERS);
415+ }
416+
417+ /**
418+ * Returns the extended modifier mask for this event.
419+ * Extended modifiers represent the state of all modal keys,
420+ * such as ALT, CTRL, META, and the mouse buttons just after
421+ * the event occurred
422+ * <P>
423+ * For example, if the user presses <b>button 1</b> followed by
424+ * <b>button 2</b>, and then releases them in the same order,
425+ * the following sequence of events is generated:
426+ * <PRE>
427+ * <code>MOUSE_PRESSED</code>: <code>BUTTON1_DOWN_MASK</code>
428+ * <code>MOUSE_PRESSED</code>: <code>BUTTON1_DOWN_MASK | BUTTON2_DOWN_MASK</code>
429+ * <code>MOUSE_RELEASED</code>: <code>BUTTON2_DOWN_MASK</code>
430+ * <code>MOUSE_CLICKED</code>: <code>BUTTON2_DOWN_MASK</code>
431+ * <code>MOUSE_RELEASED</code>:
432+ * <code>MOUSE_CLICKED</code>:
433+ * </PRE>
434+ * <P>
435+ * It is not recommended to compare the return value of this method
436+ * using <code>==</code> because new modifiers can be added in the future.
437+ * For example, the appropriate way to check that SHIFT and BUTTON1 are
438+ * down, but CTRL is up is demonstrated by the following code:
439+ * <PRE>
440+ * int onmask = SHIFT_DOWN_MASK | BUTTON1_DOWN_MASK;
441+ * int offmask = CTRL_DOWN_MASK;
442+ * if ((event.getModifiersEx() & (onmask | offmask)) == onmask) {
443+ * ...
444+ * }
445+ * </PRE>
446+ * The above code will work even if new modifiers are added.
447+ *
448+ * @since 1.4
449+ */
450+ public int getModifiersEx() {
451+ return modifiers & ~JDK_1_3_MODIFIERS;
452+ }
453+
454+ /**
455+ * Consumes this event so that it will not be processed
456+ * in the default manner by the source which originated it.
457+ */
458+ public void consume() {
459+ consumed = true;
460+ }
461+
462+ /**
463+ * Returns whether or not this event has been consumed.
464+ * @see #consume
465+ */
466+ public boolean isConsumed() {
467+ return consumed;
468+ }
469+
470+ // state serialization compatibility with JDK 1.1
471+ static final long serialVersionUID = -2482525981698309786L;
472+
473+ /**
474+ * Returns a String describing the extended modifier keys and
475+ * mouse buttons, such as "Shift", "Button1", or "Ctrl+Shift".
476+ * These strings can be localized by changing the
477+ * <code>awt.properties</code> file.
478+ * <p>
479+ * Note that passing negative parameter is incorrect,
480+ * and will cause the returning an unspecified string.
481+ * Zero parameter means that no modifiers were passed and will
482+ * cause the returning an empty string.
483+ *
484+ * @param modifiers a modifier mask describing the extended
485+ * modifier keys and mouse buttons for the event
486+ * @return a text description of the combination of extended
487+ * modifier keys and mouse buttons that were held down
488+ * during the event.
489+ * @since 1.4
490+ */
491+ public static String getModifiersExText(int modifiers) {
492+ StringBuilder buf = new StringBuilder();
493+ if ((modifiers & InputEvent.META_DOWN_MASK) != 0) {
494+ buf.append(Toolkit.getProperty("AWT.meta", "Meta"));
495+ buf.append("+");
496+ }
497+ if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
498+ buf.append(Toolkit.getProperty("AWT.control", "Ctrl"));
499+ buf.append("+");
500+ }
501+ if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0) {
502+ buf.append(Toolkit.getProperty("AWT.alt", "Alt"));
503+ buf.append("+");
504+ }
505+ if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) {
506+ buf.append(Toolkit.getProperty("AWT.shift", "Shift"));
507+ buf.append("+");
508+ }
509+ if ((modifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) {
510+ buf.append(Toolkit.getProperty("AWT.altGraph", "Alt Graph"));
511+ buf.append("+");
512+ }
513+
514+ int buttonNumber = 1;
515+ for (int mask : InputEvent.BUTTON_DOWN_MASK){
516+ if ((modifiers & mask) != 0) {
517+ buf.append(Toolkit.getProperty("AWT.button"+buttonNumber, "Button"+buttonNumber));
518+ buf.append("+");
519+ }
520+ buttonNumber++;
521+ }
522+ if (buf.length() > 0) {
523+ buf.setLength(buf.length()-1); // remove trailing '+'
524+ }
525+ return buf.toString();
526+ }
527+}
java/pkg/java/awt/event/InputMethodEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/InputMethodEvent.java+416−0
@@ -0,0 +1,416 @@
1+/*
2+ * Copyright (c) 1997, 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.event;
27+
28+import java.awt.AWTEvent;
29+import java.awt.Component;
30+import java.awt.EventQueue;
31+import java.awt.font.TextHitInfo;
32+import java.io.IOException;
33+import java.io.ObjectInputStream;
34+import java.text.AttributedCharacterIterator;
35+import java.text.CharacterIterator;
36+
37+/**
38+ * Input method events contain information about text that is being
39+ * composed using an input method. Whenever the text changes, the
40+ * input method sends an event. If the text component that's currently
41+ * using the input method is an active client, the event is dispatched
42+ * to that component. Otherwise, it is dispatched to a separate
43+ * composition window.
44+ *
45+ * <p>
46+ * The text included with the input method event consists of two parts:
47+ * committed text and composed text. Either part may be empty. The two
48+ * parts together replace any uncommitted composed text sent in previous events,
49+ * or the currently selected committed text.
50+ * Committed text should be integrated into the text component's persistent
51+ * data, it will not be sent again. Composed text may be sent repeatedly,
52+ * with changes to reflect the user's editing operations. Committed text
53+ * always precedes composed text.
54+ *
55+ * @author JavaSoft Asia/Pacific
56+ * @since 1.2
57+ */
58+
59+public class InputMethodEvent extends AWTEvent {
60+
61+ /**
62+ * Serial Version ID.
63+ */
64+ private static final long serialVersionUID = 4727190874778922661L;
65+
66+ /**
67+ * Marks the first integer id for the range of input method event ids.
68+ */
69+ public static final int INPUT_METHOD_FIRST = 1100;
70+
71+ /**
72+ * The event type indicating changed input method text. This event is
73+ * generated by input methods while processing input.
74+ */
75+ public static final int INPUT_METHOD_TEXT_CHANGED = INPUT_METHOD_FIRST;
76+
77+ /**
78+ * The event type indicating a changed insertion point in input method text.
79+ * This event is
80+ * generated by input methods while processing input if only the caret changed.
81+ */
82+ public static final int CARET_POSITION_CHANGED = INPUT_METHOD_FIRST + 1;
83+
84+ /**
85+ * Marks the last integer id for the range of input method event ids.
86+ */
87+ public static final int INPUT_METHOD_LAST = INPUT_METHOD_FIRST + 1;
88+
89+ /**
90+ * The time stamp that indicates when the event was created.
91+ *
92+ * @serial
93+ * @see #getWhen
94+ * @since 1.4
95+ */
96+ long when;
97+
98+ // Text object
99+ private transient AttributedCharacterIterator text;
100+ private transient int committedCharacterCount;
101+ private transient TextHitInfo caret;
102+ private transient TextHitInfo visiblePosition;
103+
104+ /**
105+ * Constructs an <code>InputMethodEvent</code> with the specified
106+ * source component, type, time, text, caret, and visiblePosition.
107+ * <p>
108+ * The offsets of caret and visiblePosition are relative to the current
109+ * composed text; that is, the composed text within <code>text</code>
110+ * if this is an <code>INPUT_METHOD_TEXT_CHANGED</code> event,
111+ * the composed text within the <code>text</code> of the
112+ * preceding <code>INPUT_METHOD_TEXT_CHANGED</code> event otherwise.
113+ * <p>Note that passing in an invalid <code>id</code> results in
114+ * unspecified behavior. This method throws an
115+ * <code>IllegalArgumentException</code> if <code>source</code>
116+ * is <code>null</code>.
117+ *
118+ * @param source the object where the event originated
119+ * @param id the event type
120+ * @param when a long integer that specifies the time the event occurred
121+ * @param text the combined committed and composed text,
122+ * committed text first; must be <code>null</code>
123+ * when the event type is <code>CARET_POSITION_CHANGED</code>;
124+ * may be <code>null</code> for
125+ * <code>INPUT_METHOD_TEXT_CHANGED</code> if there's no
126+ * committed or composed text
127+ * @param committedCharacterCount the number of committed
128+ * characters in the text
129+ * @param caret the caret (a.k.a. insertion point);
130+ * <code>null</code> if there's no caret within current
131+ * composed text
132+ * @param visiblePosition the position that's most important
133+ * to be visible; <code>null</code> if there's no
134+ * recommendation for a visible position within current
135+ * composed text
136+ * @throws IllegalArgumentException if <code>id</code> is not
137+ * in the range
138+ * <code>INPUT_METHOD_FIRST</code>..<code>INPUT_METHOD_LAST</code>;
139+ * or if id is <code>CARET_POSITION_CHANGED</code> and
140+ * <code>text</code> is not <code>null</code>;
141+ * or if <code>committedCharacterCount</code> is not in the range
142+ * <code>0</code>..<code>(text.getEndIndex() - text.getBeginIndex())</code>
143+ * @throws IllegalArgumentException if <code>source</code> is null
144+ *
145+ * @since 1.4
146+ */
147+ public InputMethodEvent(Component source, int id, long when,
148+ AttributedCharacterIterator text, int committedCharacterCount,
149+ TextHitInfo caret, TextHitInfo visiblePosition) {
150+ super(source, id);
151+ if (id < INPUT_METHOD_FIRST || id > INPUT_METHOD_LAST) {
152+ throw new IllegalArgumentException("id outside of valid range");
153+ }
154+
155+ if (id == CARET_POSITION_CHANGED && text != null) {
156+ throw new IllegalArgumentException("text must be null for CARET_POSITION_CHANGED");
157+ }
158+
159+ this.when = when;
160+ this.text = text;
161+ int textLength = 0;
162+ if (text != null) {
163+ textLength = text.getEndIndex() - text.getBeginIndex();
164+ }
165+
166+ if (committedCharacterCount < 0 || committedCharacterCount > textLength) {
167+ throw new IllegalArgumentException("committedCharacterCount outside of valid range");
168+ }
169+ this.committedCharacterCount = committedCharacterCount;
170+
171+ this.caret = caret;
172+ this.visiblePosition = visiblePosition;
173+ }
174+
175+ /**
176+ * Constructs an <code>InputMethodEvent</code> with the specified
177+ * source component, type, text, caret, and visiblePosition.
178+ * <p>
179+ * The offsets of caret and visiblePosition are relative to the current
180+ * composed text; that is, the composed text within <code>text</code>
181+ * if this is an <code>INPUT_METHOD_TEXT_CHANGED</code> event,
182+ * the composed text within the <code>text</code> of the
183+ * preceding <code>INPUT_METHOD_TEXT_CHANGED</code> event otherwise.
184+ * The time stamp for this event is initialized by invoking
185+ * {@link java.awt.EventQueue#getMostRecentEventTime()}.
186+ * <p>Note that passing in an invalid <code>id</code> results in
187+ * unspecified behavior. This method throws an
188+ * <code>IllegalArgumentException</code> if <code>source</code>
189+ * is <code>null</code>.
190+ *
191+ * @param source the object where the event originated
192+ * @param id the event type
193+ * @param text the combined committed and composed text,
194+ * committed text first; must be <code>null</code>
195+ * when the event type is <code>CARET_POSITION_CHANGED</code>;
196+ * may be <code>null</code> for
197+ * <code>INPUT_METHOD_TEXT_CHANGED</code> if there's no
198+ * committed or composed text
199+ * @param committedCharacterCount the number of committed
200+ * characters in the text
201+ * @param caret the caret (a.k.a. insertion point);
202+ * <code>null</code> if there's no caret within current
203+ * composed text
204+ * @param visiblePosition the position that's most important
205+ * to be visible; <code>null</code> if there's no
206+ * recommendation for a visible position within current
207+ * composed text
208+ * @throws IllegalArgumentException if <code>id</code> is not
209+ * in the range
210+ * <code>INPUT_METHOD_FIRST</code>..<code>INPUT_METHOD_LAST</code>;
211+ * or if id is <code>CARET_POSITION_CHANGED</code> and
212+ * <code>text</code> is not <code>null</code>;
213+ * or if <code>committedCharacterCount</code> is not in the range
214+ * <code>0</code>..<code>(text.getEndIndex() - text.getBeginIndex())</code>
215+ * @throws IllegalArgumentException if <code>source</code> is null
216+ */
217+ public InputMethodEvent(Component source, int id,
218+ AttributedCharacterIterator text, int committedCharacterCount,
219+ TextHitInfo caret, TextHitInfo visiblePosition) {
220+ this(source, id, EventQueue.getMostRecentEventTime(), text,
221+ committedCharacterCount, caret, visiblePosition);
222+ }
223+
224+ /**
225+ * Constructs an <code>InputMethodEvent</code> with the
226+ * specified source component, type, caret, and visiblePosition.
227+ * The text is set to <code>null</code>,
228+ * <code>committedCharacterCount</code> to 0.
229+ * <p>
230+ * The offsets of <code>caret</code> and <code>visiblePosition</code>
231+ * are relative to the current composed text; that is,
232+ * the composed text within the <code>text</code> of the
233+ * preceding <code>INPUT_METHOD_TEXT_CHANGED</code> event if the
234+ * event being constructed as a <code>CARET_POSITION_CHANGED</code> event.
235+ * For an <code>INPUT_METHOD_TEXT_CHANGED</code> event without text,
236+ * <code>caret</code> and <code>visiblePosition</code> must be
237+ * <code>null</code>.
238+ * The time stamp for this event is initialized by invoking
239+ * {@link java.awt.EventQueue#getMostRecentEventTime()}.
240+ * <p>Note that passing in an invalid <code>id</code> results in
241+ * unspecified behavior. This method throws an
242+ * <code>IllegalArgumentException</code> if <code>source</code>
243+ * is <code>null</code>.
244+ *
245+ * @param source the object where the event originated
246+ * @param id the event type
247+ * @param caret the caret (a.k.a. insertion point);
248+ * <code>null</code> if there's no caret within current
249+ * composed text
250+ * @param visiblePosition the position that's most important
251+ * to be visible; <code>null</code> if there's no
252+ * recommendation for a visible position within current
253+ * composed text
254+ * @throws IllegalArgumentException if <code>id</code> is not
255+ * in the range
256+ * <code>INPUT_METHOD_FIRST</code>..<code>INPUT_METHOD_LAST</code>
257+ * @throws IllegalArgumentException if <code>source</code> is null
258+ */
259+ public InputMethodEvent(Component source, int id, TextHitInfo caret,
260+ TextHitInfo visiblePosition) {
261+ this(source, id, EventQueue.getMostRecentEventTime(), null,
262+ 0, caret, visiblePosition);
263+ }
264+
265+ /**
266+ * Gets the combined committed and composed text.
267+ * Characters from index 0 to index <code>getCommittedCharacterCount() - 1</code> are committed
268+ * text, the remaining characters are composed text.
269+ *
270+ * @return the text.
271+ * Always null for CARET_POSITION_CHANGED;
272+ * may be null for INPUT_METHOD_TEXT_CHANGED if there's no composed or committed text.
273+ */
274+ public AttributedCharacterIterator getText() {
275+ return text;
276+ }
277+
278+ /**
279+ * Gets the number of committed characters in the text.
280+ */
281+ public int getCommittedCharacterCount() {
282+ return committedCharacterCount;
283+ }
284+
285+ /**
286+ * Gets the caret.
287+ * <p>
288+ * The offset of the caret is relative to the current
289+ * composed text; that is, the composed text within getText()
290+ * if this is an <code>INPUT_METHOD_TEXT_CHANGED</code> event,
291+ * the composed text within getText() of the
292+ * preceding <code>INPUT_METHOD_TEXT_CHANGED</code> event otherwise.
293+ *
294+ * @return the caret (a.k.a. insertion point).
295+ * Null if there's no caret within current composed text.
296+ */
297+ public TextHitInfo getCaret() {
298+ return caret;
299+ }
300+
301+ /**
302+ * Gets the position that's most important to be visible.
303+ * <p>
304+ * The offset of the visible position is relative to the current
305+ * composed text; that is, the composed text within getText()
306+ * if this is an <code>INPUT_METHOD_TEXT_CHANGED</code> event,
307+ * the composed text within getText() of the
308+ * preceding <code>INPUT_METHOD_TEXT_CHANGED</code> event otherwise.
309+ *
310+ * @return the position that's most important to be visible.
311+ * Null if there's no recommendation for a visible position within current composed text.
312+ */
313+ public TextHitInfo getVisiblePosition() {
314+ return visiblePosition;
315+ }
316+
317+ /**
318+ * Consumes this event so that it will not be processed
319+ * in the default manner by the source which originated it.
320+ */
321+ public void consume() {
322+ consumed = true;
323+ }
324+
325+ /**
326+ * Returns whether or not this event has been consumed.
327+ * @see #consume
328+ */
329+ public boolean isConsumed() {
330+ return consumed;
331+ }
332+
333+ /**
334+ * Returns the time stamp of when this event occurred.
335+ *
336+ * @return this event's timestamp
337+ * @since 1.4
338+ */
339+ public long getWhen() {
340+ return when;
341+ }
342+
343+ /**
344+ * Returns a parameter string identifying this event.
345+ * This method is useful for event-logging and for debugging.
346+ * It contains the event ID in text form, the characters of the
347+ * committed and composed text
348+ * separated by "+", the number of committed characters,
349+ * the caret, and the visible position.
350+ *
351+ * @return a string identifying the event and its attributes
352+ */
353+ public String paramString() {
354+ String typeStr;
355+ switch(id) {
356+ case INPUT_METHOD_TEXT_CHANGED:
357+ typeStr = "INPUT_METHOD_TEXT_CHANGED";
358+ break;
359+ case CARET_POSITION_CHANGED:
360+ typeStr = "CARET_POSITION_CHANGED";
361+ break;
362+ default:
363+ typeStr = "unknown type";
364+ }
365+
366+ String textString;
367+ if (text == null) {
368+ textString = "no text";
369+ } else {
370+ StringBuilder textBuffer = new StringBuilder("\"");
371+ int committedCharacterCount = this.committedCharacterCount;
372+ char c = text.first();
373+ while (committedCharacterCount-- > 0) {
374+ textBuffer.append(c);
375+ c = text.next();
376+ }
377+ textBuffer.append("\" + \"");
378+ while (c != CharacterIterator.DONE) {
379+ textBuffer.append(c);
380+ c = text.next();
381+ }
382+ textBuffer.append("\"");
383+ textString = textBuffer.toString();
384+ }
385+
386+ String countString = committedCharacterCount + " characters committed";
387+
388+ String caretString;
389+ if (caret == null) {
390+ caretString = "no caret";
391+ } else {
392+ caretString = "caret: " + caret.toString();
393+ }
394+
395+ String visiblePositionString;
396+ if (visiblePosition == null) {
397+ visiblePositionString = "no visible position";
398+ } else {
399+ visiblePositionString = "visible position: " + visiblePosition.toString();
400+ }
401+
402+ return typeStr + ", " + textString + ", " + countString + ", " + caretString + ", " + visiblePositionString;
403+ }
404+
405+ /**
406+ * Initializes the <code>when</code> field if it is not present in the
407+ * object input stream. In that case, the field will be initialized by
408+ * invoking {@link java.awt.EventQueue#getMostRecentEventTime()}.
409+ */
410+ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
411+ s.defaultReadObject();
412+ if (when == 0) {
413+ when = EventQueue.getMostRecentEventTime();
414+ }
415+ }
416+}
java/pkg/java/awt/event/InputMethodListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/InputMethodListener.java+56−0
@@ -0,0 +1,56 @@
1+/*
2+ * Copyright (c) 1997, 1999, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving input method events. A text editing
32+ * component has to install an input method event listener in order to work
33+ * with input methods.
34+ *
35+ * <p>
36+ * The text editing component also has to provide an instance of InputMethodRequests.
37+ *
38+ * @author JavaSoft Asia/Pacific
39+ * @see InputMethodEvent
40+ * @see java.awt.im.InputMethodRequests
41+ * @since 1.2
42+ */
43+
44+public interface InputMethodListener extends EventListener {
45+
46+ /**
47+ * Invoked when the text entered through an input method has changed.
48+ */
49+ void inputMethodTextChanged(InputMethodEvent event);
50+
51+ /**
52+ * Invoked when the caret within composed text has changed.
53+ */
54+ void caretPositionChanged(InputMethodEvent event);
55+
56+}
java/pkg/java/awt/event/InvocationEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/InvocationEvent.java+351−0
@@ -0,0 +1,351 @@
1+/*
2+ * Copyright (c) 1998, 2008, 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.event;
27+
28+import java.awt.ActiveEvent;
29+import java.awt.AWTEvent;
30+
31+/**
32+ * An event which executes the <code>run()</code> method on a <code>Runnable
33+ * </code> when dispatched by the AWT event dispatcher thread. This class can
34+ * be used as a reference implementation of <code>ActiveEvent</code> rather
35+ * than declaring a new class and defining <code>dispatch()</code>.<p>
36+ *
37+ * Instances of this class are placed on the <code>EventQueue</code> by calls
38+ * to <code>invokeLater</code> and <code>invokeAndWait</code>. Client code
39+ * can use this fact to write replacement functions for <code>invokeLater
40+ * </code> and <code>invokeAndWait</code> without writing special-case code
41+ * in any <code>AWTEventListener</code> objects.
42+ * <p>
43+ * An unspecified behavior will be caused if the {@code id} parameter
44+ * of any particular {@code InvocationEvent} instance is not
45+ * in the range from {@code INVOCATION_FIRST} to {@code INVOCATION_LAST}.
46+ *
47+ * @author Fred Ecks
48+ * @author David Mendenhall
49+ *
50+ * @see java.awt.ActiveEvent
51+ * @see java.awt.EventQueue#invokeLater
52+ * @see java.awt.EventQueue#invokeAndWait
53+ * @see AWTEventListener
54+ *
55+ * @since 1.2
56+ */
57+public class InvocationEvent extends AWTEvent implements ActiveEvent {
58+
59+ /**
60+ * Marks the first integer id for the range of invocation event ids.
61+ */
62+ public static final int INVOCATION_FIRST = 1200;
63+
64+ /**
65+ * The default id for all InvocationEvents.
66+ */
67+ public static final int INVOCATION_DEFAULT = INVOCATION_FIRST;
68+
69+ /**
70+ * Marks the last integer id for the range of invocation event ids.
71+ */
72+ public static final int INVOCATION_LAST = INVOCATION_DEFAULT;
73+
74+ /**
75+ * The Runnable whose run() method will be called.
76+ */
77+ protected Runnable runnable;
78+
79+ /**
80+ * The (potentially null) Object whose notifyAll() method will be called
81+ * immediately after the Runnable.run() method has returned or thrown an exception.
82+ *
83+ * @see #isDispatched
84+ */
85+ protected Object notifier;
86+
87+ /**
88+ * Indicates whether the <code>run()</code> method of the <code>runnable</code>
89+ * was executed or not.
90+ *
91+ * @see #isDispatched
92+ * @since 1.7
93+ */
94+ private volatile boolean dispatched = false;
95+
96+ /**
97+ * Set to true if dispatch() catches Throwable and stores it in the
98+ * exception instance variable. If false, Throwables are propagated up
99+ * to the EventDispatchThread's dispatch loop.
100+ */
101+ protected boolean catchExceptions;
102+
103+ /**
104+ * The (potentially null) Exception thrown during execution of the
105+ * Runnable.run() method. This variable will also be null if a particular
106+ * instance does not catch exceptions.
107+ */
108+ private Exception exception = null;
109+
110+ /**
111+ * The (potentially null) Throwable thrown during execution of the
112+ * Runnable.run() method. This variable will also be null if a particular
113+ * instance does not catch exceptions.
114+ */
115+ private Throwable throwable = null;
116+
117+ /**
118+ * The timestamp of when this event occurred.
119+ *
120+ * @serial
121+ * @see #getWhen
122+ */
123+ private long when;
124+
125+ /*
126+ * JDK 1.1 serialVersionUID.
127+ */
128+ private static final long serialVersionUID = 436056344909459450L;
129+
130+ /**
131+ * Constructs an <code>InvocationEvent</code> with the specified
132+ * source which will execute the runnable's <code>run</code>
133+ * method when dispatched.
134+ * <p>This is a convenience constructor. An invocation of the form
135+ * <tt>InvocationEvent(source, runnable)</tt>
136+ * behaves in exactly the same way as the invocation of
137+ * <tt>{@link #InvocationEvent(Object, Runnable, Object, boolean) InvocationEvent}(source, runnable, null, false)</tt>.
138+ * <p> This method throws an <code>IllegalArgumentException</code>
139+ * if <code>source</code> is <code>null</code>.
140+ *
141+ * @param source The <code>Object</code> that originated the event
142+ * @param runnable The <code>Runnable</code> whose <code>run</code>
143+ * method will be executed
144+ * @throws IllegalArgumentException if <code>source</code> is null
145+ *
146+ * @see #getSource()
147+ * @see #InvocationEvent(Object, Runnable, Object, boolean)
148+ */
149+ public InvocationEvent(Object source, Runnable runnable) {
150+ this(source, runnable, null, false);
151+ }
152+
153+ /**
154+ * Constructs an <code>InvocationEvent</code> with the specified
155+ * source which will execute the runnable's <code>run</code>
156+ * method when dispatched. If notifier is non-<code>null</code>,
157+ * <code>notifyAll()</code> will be called on it
158+ * immediately after <code>run</code> has returned or thrown an exception.
159+ * <p>An invocation of the form <tt>InvocationEvent(source,
160+ * runnable, notifier, catchThrowables)</tt>
161+ * behaves in exactly the same way as the invocation of
162+ * <tt>{@link #InvocationEvent(Object, int, Runnable, Object, boolean) InvocationEvent}(source, InvocationEvent.INVOCATION_DEFAULT, runnable, notifier, catchThrowables)</tt>.
163+ * <p>This method throws an <code>IllegalArgumentException</code>
164+ * if <code>source</code> is <code>null</code>.
165+ *
166+ * @param source The <code>Object</code> that originated
167+ * the event
168+ * @param runnable The <code>Runnable</code> whose
169+ * <code>run</code> method will be
170+ * executed
171+ * @param notifier The {@code Object} whose <code>notifyAll</code>
172+ * method will be called after
173+ * <code>Runnable.run</code> has returned or
174+ * thrown an exception
175+ * @param catchThrowables Specifies whether <code>dispatch</code>
176+ * should catch Throwable when executing
177+ * the <code>Runnable</code>'s <code>run</code>
178+ * method, or should instead propagate those
179+ * Throwables to the EventDispatchThread's
180+ * dispatch loop
181+ * @throws IllegalArgumentException if <code>source</code> is null
182+ *
183+ * @see #getSource()
184+ * @see #InvocationEvent(Object, int, Runnable, Object, boolean)
185+ */
186+ public InvocationEvent(Object source, Runnable runnable, Object notifier,
187+ boolean catchThrowables) {
188+ this(source, INVOCATION_DEFAULT, runnable, notifier, catchThrowables);
189+ }
190+
191+ /**
192+ * Constructs an <code>InvocationEvent</code> with the specified
193+ * source and ID which will execute the runnable's <code>run</code>
194+ * method when dispatched. If notifier is non-<code>null</code>,
195+ * <code>notifyAll</code> will be called on it immediately after
196+ * <code>run</code> has returned or thrown an exception.
197+ * <p>This method throws an
198+ * <code>IllegalArgumentException</code> if <code>source</code>
199+ * is <code>null</code>.
200+ *
201+ * @param source The <code>Object</code> that originated
202+ * the event
203+ * @param id An integer indicating the type of event.
204+ * For information on allowable values, see
205+ * the class description for {@link InvocationEvent}
206+ * @param runnable The <code>Runnable</code> whose
207+ * <code>run</code> method will be executed
208+ * @param notifier The <code>Object</code> whose <code>notifyAll</code>
209+ * method will be called after
210+ * <code>Runnable.run</code> has returned or
211+ * thrown an exception
212+ * @param catchThrowables Specifies whether <code>dispatch</code>
213+ * should catch Throwable when executing the
214+ * <code>Runnable</code>'s <code>run</code>
215+ * method, or should instead propagate those
216+ * Throwables to the EventDispatchThread's
217+ * dispatch loop
218+ * @throws IllegalArgumentException if <code>source</code> is null
219+ * @see #getSource()
220+ * @see #getID()
221+ */
222+ protected InvocationEvent(Object source, int id, Runnable runnable,
223+ Object notifier, boolean catchThrowables) {
224+ super(source, id);
225+ this.runnable = runnable;
226+ this.notifier = notifier;
227+ this.catchExceptions = catchThrowables;
228+ this.when = System.currentTimeMillis();
229+ }
230+
231+ /**
232+ * Executes the Runnable's <code>run()</code> method and notifies the
233+ * notifier (if any) when <code>run()</code> has returned or thrown an exception.
234+ *
235+ * @see #isDispatched
236+ */
237+ public void dispatch() {
238+ try {
239+ if (catchExceptions) {
240+ try {
241+ runnable.run();
242+ }
243+ catch (Throwable t) {
244+ if (t instanceof Exception) {
245+ exception = (Exception) t;
246+ }
247+ throwable = t;
248+ }
249+ }
250+ else {
251+ runnable.run();
252+ }
253+ } finally {
254+ dispatched = true;
255+
256+ if (notifier != null) {
257+ synchronized (notifier) {
258+ notifier.notifyAll();
259+ }
260+ }
261+ }
262+ }
263+
264+ /**
265+ * Returns any Exception caught while executing the Runnable's <code>run()
266+ * </code> method.
267+ *
268+ * @return A reference to the Exception if one was thrown; null if no
269+ * Exception was thrown or if this InvocationEvent does not
270+ * catch exceptions
271+ */
272+ public Exception getException() {
273+ return (catchExceptions) ? exception : null;
274+ }
275+
276+ /**
277+ * Returns any Throwable caught while executing the Runnable's <code>run()
278+ * </code> method.
279+ *
280+ * @return A reference to the Throwable if one was thrown; null if no
281+ * Throwable was thrown or if this InvocationEvent does not
282+ * catch Throwables
283+ * @since 1.5
284+ */
285+ public Throwable getThrowable() {
286+ return (catchExceptions) ? throwable : null;
287+ }
288+
289+ /**
290+ * Returns the timestamp of when this event occurred.
291+ *
292+ * @return this event's timestamp
293+ * @since 1.4
294+ */
295+ public long getWhen() {
296+ return when;
297+ }
298+
299+ /**
300+ * Returns {@code true} if the event is dispatched or any exception is
301+ * thrown while dispatching, {@code false} otherwise. The method should
302+ * be called by a waiting thread that calls the {@code notifier.wait()} method.
303+ * Since spurious wakeups are possible (as explained in {@link Object#wait()}),
304+ * this method should be used in a waiting loop to ensure that the event
305+ * got dispatched:
306+ * <pre>
307+ * while (!event.isDispatched()) {
308+ * notifier.wait();
309+ * }
310+ * </pre>
311+ * If the waiting thread wakes up without dispatching the event,
312+ * the {@code isDispatched()} method returns {@code false}, and
313+ * the {@code while} loop executes once more, thus, causing
314+ * the awakened thread to revert to the waiting mode.
315+ * <p>
316+ * If the {@code notifier.notifyAll()} happens before the waiting thread
317+ * enters the {@code notifier.wait()} method, the {@code while} loop ensures
318+ * that the waiting thread will not enter the {@code notifier.wait()} method.
319+ * Otherwise, there is no guarantee that the waiting thread will ever be woken
320+ * from the wait.
321+ *
322+ * @return {@code true} if the event has been dispatched, or any exception
323+ * has been thrown while dispatching, {@code false} otherwise
324+ * @see #dispatch
325+ * @see #notifier
326+ * @see #catchExceptions
327+ * @since 1.7
328+ */
329+ public boolean isDispatched() {
330+ return dispatched;
331+ }
332+
333+ /**
334+ * Returns a parameter string identifying this event.
335+ * This method is useful for event-logging and for debugging.
336+ *
337+ * @return A string identifying the event and its attributes
338+ */
339+ public String paramString() {
340+ String typeStr;
341+ switch(id) {
342+ case INVOCATION_DEFAULT:
343+ typeStr = "INVOCATION_DEFAULT";
344+ break;
345+ default:
346+ typeStr = "unknown type";
347+ }
348+ return typeStr + ",runnable=" + runnable + ",notifier=" + notifier +
349+ ",catchExceptions=" + catchExceptions + ",when=" + when;
350+ }
351+}
java/pkg/java/awt/event/ItemEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/ItemEvent.java+202−0
@@ -0,0 +1,202 @@
1+/*
2+ * Copyright (c) 1996, 2008, 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.event;
27+
28+import java.awt.AWTEvent;
29+import java.awt.ItemSelectable;
30+
31+/**
32+ * A semantic event which indicates that an item was selected or deselected.
33+ * This high-level event is generated by an ItemSelectable object (such as a
34+ * List) when an item is selected or deselected by the user.
35+ * The event is passed to every <code>ItemListener</code> object which
36+ * registered to receive such events using the component's
37+ * <code>addItemListener</code> method.
38+ * <P>
39+ * The object that implements the <code>ItemListener</code> interface gets
40+ * this <code>ItemEvent</code> when the event occurs. The listener is
41+ * spared the details of processing individual mouse movements and mouse
42+ * clicks, and can instead process a "meaningful" (semantic) event like
43+ * "item selected" or "item deselected".
44+ * <p>
45+ * An unspecified behavior will be caused if the {@code id} parameter
46+ * of any particular {@code ItemEvent} instance is not
47+ * in the range from {@code ITEM_FIRST} to {@code ITEM_LAST}.
48+ * <p>
49+ * The {@code stateChange} of any {@code ItemEvent} instance takes one of the following
50+ * values:
51+ * <ul>
52+ * <li> {@code ItemEvent.SELECTED}
53+ * <li> {@code ItemEvent.DESELECTED}
54+ * </ul>
55+ * Assigning the value different from listed above will cause an unspecified behavior.
56+ *
57+ * @author Carl Quinn
58+ *
59+ * @see java.awt.ItemSelectable
60+ * @see ItemListener
61+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/itemlistener.html">Tutorial: Writing an Item Listener</a>
62+ *
63+ * @since 1.1
64+ */
65+public class ItemEvent extends AWTEvent {
66+
67+ /**
68+ * The first number in the range of ids used for item events.
69+ */
70+ public static final int ITEM_FIRST = 701;
71+
72+ /**
73+ * The last number in the range of ids used for item events.
74+ */
75+ public static final int ITEM_LAST = 701;
76+
77+ /**
78+ * This event id indicates that an item's state changed.
79+ */
80+ public static final int ITEM_STATE_CHANGED = ITEM_FIRST; //Event.LIST_SELECT
81+
82+ /**
83+ * This state-change value indicates that an item was selected.
84+ */
85+ public static final int SELECTED = 1;
86+
87+ /**
88+ * This state-change-value indicates that a selected item was deselected.
89+ */
90+ public static final int DESELECTED = 2;
91+
92+ /**
93+ * The item whose selection state has changed.
94+ *
95+ * @serial
96+ * @see #getItem()
97+ */
98+ Object item;
99+
100+ /**
101+ * <code>stateChange</code> indicates whether the <code>item</code>
102+ * was selected or deselected.
103+ *
104+ * @serial
105+ * @see #getStateChange()
106+ */
107+ int stateChange;
108+
109+ /*
110+ * JDK 1.1 serialVersionUID
111+ */
112+ private static final long serialVersionUID = -608708132447206933L;
113+
114+ /**
115+ * Constructs an <code>ItemEvent</code> object.
116+ * <p> This method throws an
117+ * <code>IllegalArgumentException</code> if <code>source</code>
118+ * is <code>null</code>.
119+ *
120+ * @param source The <code>ItemSelectable</code> object
121+ * that originated the event
122+ * @param id The integer that identifies the event type.
123+ * For information on allowable values, see
124+ * the class description for {@link ItemEvent}
125+ * @param item An object -- the item affected by the event
126+ * @param stateChange An integer that indicates whether the item was
127+ * selected or deselected.
128+ * For information on allowable values, see
129+ * the class description for {@link ItemEvent}
130+ * @throws IllegalArgumentException if <code>source</code> is null
131+ * @see #getItemSelectable()
132+ * @see #getID()
133+ * @see #getStateChange()
134+ */
135+ public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
136+ super(source, id);
137+ this.item = item;
138+ this.stateChange = stateChange;
139+ }
140+
141+ /**
142+ * Returns the originator of the event.
143+ *
144+ * @return the ItemSelectable object that originated the event.
145+ */
146+ public ItemSelectable getItemSelectable() {
147+ return (ItemSelectable)source;
148+ }
149+
150+ /**
151+ * Returns the item affected by the event.
152+ *
153+ * @return the item (object) that was affected by the event
154+ */
155+ public Object getItem() {
156+ return item;
157+ }
158+
159+ /**
160+ * Returns the type of state change (selected or deselected).
161+ *
162+ * @return an integer that indicates whether the item was selected
163+ * or deselected
164+ *
165+ * @see #SELECTED
166+ * @see #DESELECTED
167+ */
168+ public int getStateChange() {
169+ return stateChange;
170+ }
171+
172+ /**
173+ * Returns a parameter string identifying this item event.
174+ * This method is useful for event-logging and for debugging.
175+ *
176+ * @return a string identifying the event and its attributes
177+ */
178+ public String paramString() {
179+ String typeStr;
180+ switch(id) {
181+ case ITEM_STATE_CHANGED:
182+ typeStr = "ITEM_STATE_CHANGED";
183+ break;
184+ default:
185+ typeStr = "unknown type";
186+ }
187+
188+ String stateStr;
189+ switch(stateChange) {
190+ case SELECTED:
191+ stateStr = "SELECTED";
192+ break;
193+ case DESELECTED:
194+ stateStr = "DESELECTED";
195+ break;
196+ default:
197+ stateStr = "unknown type";
198+ }
199+ return typeStr + ",item="+item + ",stateChange="+stateStr;
200+ }
201+
202+}
java/pkg/java/awt/event/ItemListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/ItemListener.java+56−0
@@ -0,0 +1,56 @@
1+/*
2+ * Copyright (c) 1996, 2006, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving item events.
32+ * The class that is interested in processing an item event
33+ * implements this interface. The object created with that
34+ * class is then registered with a component using the
35+ * component's <code>addItemListener</code> method. When an
36+ * item-selection event occurs, the listener object's
37+ * <code>itemStateChanged</code> method is invoked.
38+ *
39+ * @author Amy Fowler
40+ *
41+ * @see java.awt.ItemSelectable
42+ * @see ItemEvent
43+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/itemlistener.html">Tutorial: Writing an Item Listener</a>
44+ *
45+ * @since 1.1
46+ */
47+public interface ItemListener extends EventListener {
48+
49+ /**
50+ * Invoked when an item has been selected or deselected by the user.
51+ * The code written for this method performs the operations
52+ * that need to occur when an item is selected (or deselected).
53+ */
54+ void itemStateChanged(ItemEvent e);
55+
56+}
java/pkg/java/awt/event/KeyAdapter.class+0−0

Binary file not shown.

java/pkg/java/awt/event/KeyAdapter.java+69−0
@@ -0,0 +1,69 @@
1+/*
2+ * Copyright (c) 1996, 2006, 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.event;
27+
28+/**
29+ * An abstract adapter class for receiving keyboard events.
30+ * The methods in this class are empty. This class exists as
31+ * convenience for creating listener objects.
32+ * <P>
33+ * Extend this class to create a <code>KeyEvent</code> listener
34+ * and override the methods for the events of interest. (If you implement the
35+ * <code>KeyListener</code> interface, you have to define all of
36+ * the methods in it. This abstract class defines null methods for them
37+ * all, so you can only have to define methods for events you care about.)
38+ * <P>
39+ * Create a listener object using the extended class and then register it with
40+ * a component using the component's <code>addKeyListener</code>
41+ * method. When a key is pressed, released, or typed,
42+ * the relevant method in the listener object is invoked,
43+ * and the <code>KeyEvent</code> is passed to it.
44+ *
45+ * @author Carl Quinn
46+ *
47+ * @see KeyEvent
48+ * @see KeyListener
49+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/keylistener.html">Tutorial: Writing a Key Listener</a>
50+ *
51+ * @since 1.1
52+ */
53+public abstract class KeyAdapter implements KeyListener {
54+ /**
55+ * Invoked when a key has been typed.
56+ * This event occurs when a key press is followed by a key release.
57+ */
58+ public void keyTyped(KeyEvent e) {}
59+
60+ /**
61+ * Invoked when a key has been pressed.
62+ */
63+ public void keyPressed(KeyEvent e) {}
64+
65+ /**
66+ * Invoked when a key has been released.
67+ */
68+ public void keyReleased(KeyEvent e) {}
69+}
java/pkg/java/awt/event/KeyEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/KeyEvent.java+1669−0
@@ -0,0 +1,1669 @@
1+/*
2+ * Copyright (c) 1996, 2009, 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.event;
27+
28+import java.awt.Event;
29+import java.awt.Component;
30+import java.awt.GraphicsEnvironment;
31+import java.awt.Toolkit;
32+import java.io.IOException;
33+import java.io.ObjectInputStream;
34+
35+/**
36+ * An event which indicates that a keystroke occurred in a component.
37+ * <p>
38+ * This low-level event is generated by a component object (such as a text
39+ * field) when a key is pressed, released, or typed.
40+ * The event is passed to every <code>KeyListener</code>
41+ * or <code>KeyAdapter</code> object which registered to receive such
42+ * events using the component's <code>addKeyListener</code> method.
43+ * (<code>KeyAdapter</code> objects implement the
44+ * <code>KeyListener</code> interface.) Each such listener object
45+ * gets this <code>KeyEvent</code> when the event occurs.
46+ * <p>
47+ * <em>"Key typed" events</em> are higher-level and generally do not depend on
48+ * the platform or keyboard layout. They are generated when a Unicode character
49+ * is entered, and are the preferred way to find out about character input.
50+ * In the simplest case, a key typed event is produced by a single key press
51+ * (e.g., 'a'). Often, however, characters are produced by series of key
52+ * presses (e.g., 'shift' + 'a'), and the mapping from key pressed events to
53+ * key typed events may be many-to-one or many-to-many. Key releases are not
54+ * usually necessary to generate a key typed event, but there are some cases
55+ * where the key typed event is not generated until a key is released (e.g.,
56+ * entering ASCII sequences via the Alt-Numpad method in Windows).
57+ * No key typed events are generated for keys that don't generate Unicode
58+ * characters (e.g., action keys, modifier keys, etc.).
59+ * <p>
60+ * The getKeyChar method always returns a valid Unicode character or
61+ * CHAR_UNDEFINED. Character input is reported by KEY_TYPED events:
62+ * KEY_PRESSED and KEY_RELEASED events are not necessarily associated
63+ * with character input. Therefore, the result of the getKeyChar method
64+ * is guaranteed to be meaningful only for KEY_TYPED events.
65+ * <p>
66+ * For key pressed and key released events, the getKeyCode method returns
67+ * the event's keyCode. For key typed events, the getKeyCode method
68+ * always returns {@code VK_UNDEFINED}. The {@code getExtendedKeyCode} method
69+ * may also be used with many international keyboard layouts.
70+ *
71+ * <p>
72+ * <em>"Key pressed" and "key released" events</em> are lower-level and depend
73+ * on the platform and keyboard layout. They are generated whenever a key is
74+ * pressed or released, and are the only way to find out about keys that don't
75+ * generate character input (e.g., action keys, modifier keys, etc.). The key
76+ * being pressed or released is indicated by the {@code getKeyCode} and {@code getExtendedKeyCode}
77+ * methods, which return a virtual key code.
78+ *
79+ * <p>
80+ * <em>Virtual key codes</em> are used to report which keyboard key has
81+ * been pressed, rather than a character generated by the combination
82+ * of one or more keystrokes (such as "A", which comes from shift and "a").
83+ *
84+ * <p>
85+ * For example, pressing the Shift key will cause a KEY_PRESSED event
86+ * with a VK_SHIFT keyCode, while pressing the 'a' key will result in
87+ * a VK_A keyCode. After the 'a' key is released, a KEY_RELEASED event
88+ * will be fired with VK_A. Separately, a KEY_TYPED event with a keyChar
89+ * value of 'A' is generated.
90+ *
91+ * <p>
92+ * Pressing and releasing a key on the keyboard results in the generating
93+ * the following key events (in order):
94+ * <PRE>
95+ * {@code KEY_PRESSED}
96+ * {@code KEY_TYPED} (is only generated if a valid Unicode character could be generated.)
97+ * {@code KEY_RELEASED}
98+ * </PRE>
99+ *
100+ * But in some cases (e.g. auto-repeat or input method is activated) the order
101+ * could be different (and platform dependent).
102+ *
103+ * <p>
104+ * Notes:
105+ * <ul>
106+ * <li>Key combinations which do not result in Unicode characters, such as action
107+ * keys like F1 and the HELP key, do not generate KEY_TYPED events.
108+ * <li>Not all keyboards or systems are capable of generating all
109+ * virtual key codes. No attempt is made in Java to generate these keys
110+ * artificially.
111+ * <li>Virtual key codes do not identify a physical key: they depend on the
112+ * platform and keyboard layout. For example, the key that generates VK_Q
113+ * when using a U.S. keyboard layout will generate VK_A when using a French
114+ * keyboard layout.
115+ * <li>The key that generates {@code VK_Q} when using a U.S. keyboard layout also
116+ * generates a unique code for Russian or Hebrew layout. There is no a
117+ * {@code VK_} constant for these and many other codes in various layouts. These codes
118+ * may be obtained by using {@code getExtendedKeyCode} and are used whenever
119+ * a {@code VK_} constant is used.
120+ * <li>Not all characters have a keycode associated with them. For example,
121+ * there is no keycode for the question mark because there is no keyboard
122+ * for which it appears on the primary layer.
123+ * <li>In order to support the platform-independent handling of action keys,
124+ * the Java platform uses a few additional virtual key constants for functions
125+ * that would otherwise have to be recognized by interpreting virtual key codes
126+ * and modifiers. For example, for Japanese Windows keyboards, VK_ALL_CANDIDATES
127+ * is returned instead of VK_CONVERT with the ALT modifier.
128+ * <li>As specified in <a href="../doc-files/FocusSpec.html">Focus Specification</a>
129+ * key events are dispatched to the focus owner by default.
130+ * </ul>
131+ *
132+ * <p>
133+ * WARNING: Aside from those keys that are defined by the Java language
134+ * (VK_ENTER, VK_BACK_SPACE, and VK_TAB), do not rely on the values of the VK_
135+ * constants. Sun reserves the right to change these values as needed
136+ * to accomodate a wider range of keyboards in the future.
137+ * <p>
138+ * An unspecified behavior will be caused if the {@code id} parameter
139+ * of any particular {@code KeyEvent} instance is not
140+ * in the range from {@code KEY_FIRST} to {@code KEY_LAST}.
141+ *
142+ * @author Carl Quinn
143+ * @author Amy Fowler
144+ * @author Norbert Lindenberg
145+ *
146+ * @see KeyAdapter
147+ * @see KeyListener
148+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/keylistener.html">Tutorial: Writing a Key Listener</a>
149+ *
150+ * @since 1.1
151+ */
152+public class KeyEvent extends InputEvent {
153+
154+ /**
155+ * Stores the state of native event dispatching system
156+ * - true, if when the event was created event proxying
157+ * mechanism was active
158+ * - false, if it was inactive
159+ * Used in Component.dispatchEventImpl to correctly dispatch
160+ * events when proxy is active
161+ */
162+ private boolean isProxyActive = false;
163+
164+ /**
165+ * The first number in the range of ids used for key events.
166+ */
167+ public static final int KEY_FIRST = 400;
168+
169+ /**
170+ * The last number in the range of ids used for key events.
171+ */
172+ public static final int KEY_LAST = 402;
173+
174+ /**
175+ * The "key typed" event. This event is generated when a character is
176+ * entered. In the simplest case, it is produced by a single key press.
177+ * Often, however, characters are produced by series of key presses, and
178+ * the mapping from key pressed events to key typed events may be
179+ * many-to-one or many-to-many.
180+ */
181+ public static final int KEY_TYPED = KEY_FIRST;
182+
183+ /**
184+ * The "key pressed" event. This event is generated when a key
185+ * is pushed down.
186+ */
187+ public static final int KEY_PRESSED = 1 + KEY_FIRST; //Event.KEY_PRESS
188+
189+ /**
190+ * The "key released" event. This event is generated when a key
191+ * is let up.
192+ */
193+ public static final int KEY_RELEASED = 2 + KEY_FIRST; //Event.KEY_RELEASE
194+
195+ /* Virtual key codes. */
196+
197+ public static final int VK_ENTER = '\n';
198+ public static final int VK_BACK_SPACE = '\b';
199+ public static final int VK_TAB = '\t';
200+ public static final int VK_CANCEL = 0x03;
201+ public static final int VK_CLEAR = 0x0C;
202+ public static final int VK_SHIFT = 0x10;
203+ public static final int VK_CONTROL = 0x11;
204+ public static final int VK_ALT = 0x12;
205+ public static final int VK_PAUSE = 0x13;
206+ public static final int VK_CAPS_LOCK = 0x14;
207+ public static final int VK_ESCAPE = 0x1B;
208+ public static final int VK_SPACE = 0x20;
209+ public static final int VK_PAGE_UP = 0x21;
210+ public static final int VK_PAGE_DOWN = 0x22;
211+ public static final int VK_END = 0x23;
212+ public static final int VK_HOME = 0x24;
213+
214+ /**
215+ * Constant for the non-numpad <b>left</b> arrow key.
216+ * @see #VK_KP_LEFT
217+ */
218+ public static final int VK_LEFT = 0x25;
219+
220+ /**
221+ * Constant for the non-numpad <b>up</b> arrow key.
222+ * @see #VK_KP_UP
223+ */
224+ public static final int VK_UP = 0x26;
225+
226+ /**
227+ * Constant for the non-numpad <b>right</b> arrow key.
228+ * @see #VK_KP_RIGHT
229+ */
230+ public static final int VK_RIGHT = 0x27;
231+
232+ /**
233+ * Constant for the non-numpad <b>down</b> arrow key.
234+ * @see #VK_KP_DOWN
235+ */
236+ public static final int VK_DOWN = 0x28;
237+
238+ /**
239+ * Constant for the comma key, ","
240+ */
241+ public static final int VK_COMMA = 0x2C;
242+
243+ /**
244+ * Constant for the minus key, "-"
245+ * @since 1.2
246+ */
247+ public static final int VK_MINUS = 0x2D;
248+
249+ /**
250+ * Constant for the period key, "."
251+ */
252+ public static final int VK_PERIOD = 0x2E;
253+
254+ /**
255+ * Constant for the forward slash key, "/"
256+ */
257+ public static final int VK_SLASH = 0x2F;
258+
259+ /** VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
260+ public static final int VK_0 = 0x30;
261+ public static final int VK_1 = 0x31;
262+ public static final int VK_2 = 0x32;
263+ public static final int VK_3 = 0x33;
264+ public static final int VK_4 = 0x34;
265+ public static final int VK_5 = 0x35;
266+ public static final int VK_6 = 0x36;
267+ public static final int VK_7 = 0x37;
268+ public static final int VK_8 = 0x38;
269+ public static final int VK_9 = 0x39;
270+
271+ /**
272+ * Constant for the semicolon key, ";"
273+ */
274+ public static final int VK_SEMICOLON = 0x3B;
275+
276+ /**
277+ * Constant for the equals key, "="
278+ */
279+ public static final int VK_EQUALS = 0x3D;
280+
281+ /** VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
282+ public static final int VK_A = 0x41;
283+ public static final int VK_B = 0x42;
284+ public static final int VK_C = 0x43;
285+ public static final int VK_D = 0x44;
286+ public static final int VK_E = 0x45;
287+ public static final int VK_F = 0x46;
288+ public static final int VK_G = 0x47;
289+ public static final int VK_H = 0x48;
290+ public static final int VK_I = 0x49;
291+ public static final int VK_J = 0x4A;
292+ public static final int VK_K = 0x4B;
293+ public static final int VK_L = 0x4C;
294+ public static final int VK_M = 0x4D;
295+ public static final int VK_N = 0x4E;
296+ public static final int VK_O = 0x4F;
297+ public static final int VK_P = 0x50;
298+ public static final int VK_Q = 0x51;
299+ public static final int VK_R = 0x52;
300+ public static final int VK_S = 0x53;
301+ public static final int VK_T = 0x54;
302+ public static final int VK_U = 0x55;
303+ public static final int VK_V = 0x56;
304+ public static final int VK_W = 0x57;
305+ public static final int VK_X = 0x58;
306+ public static final int VK_Y = 0x59;
307+ public static final int VK_Z = 0x5A;
308+
309+ /**
310+ * Constant for the open bracket key, "["
311+ */
312+ public static final int VK_OPEN_BRACKET = 0x5B;
313+
314+ /**
315+ * Constant for the back slash key, "\"
316+ */
317+ public static final int VK_BACK_SLASH = 0x5C;
318+
319+ /**
320+ * Constant for the close bracket key, "]"
321+ */
322+ public static final int VK_CLOSE_BRACKET = 0x5D;
323+
324+ public static final int VK_NUMPAD0 = 0x60;
325+ public static final int VK_NUMPAD1 = 0x61;
326+ public static final int VK_NUMPAD2 = 0x62;
327+ public static final int VK_NUMPAD3 = 0x63;
328+ public static final int VK_NUMPAD4 = 0x64;
329+ public static final int VK_NUMPAD5 = 0x65;
330+ public static final int VK_NUMPAD6 = 0x66;
331+ public static final int VK_NUMPAD7 = 0x67;
332+ public static final int VK_NUMPAD8 = 0x68;
333+ public static final int VK_NUMPAD9 = 0x69;
334+ public static final int VK_MULTIPLY = 0x6A;
335+ public static final int VK_ADD = 0x6B;
336+
337+ /**
338+ * This constant is obsolete, and is included only for backwards
339+ * compatibility.
340+ * @see #VK_SEPARATOR
341+ */
342+ public static final int VK_SEPARATER = 0x6C;
343+
344+ /**
345+ * Constant for the Numpad Separator key.
346+ * @since 1.4
347+ */
348+ public static final int VK_SEPARATOR = VK_SEPARATER;
349+
350+ public static final int VK_SUBTRACT = 0x6D;
351+ public static final int VK_DECIMAL = 0x6E;
352+ public static final int VK_DIVIDE = 0x6F;
353+ public static final int VK_DELETE = 0x7F; /* ASCII DEL */
354+ public static final int VK_NUM_LOCK = 0x90;
355+ public static final int VK_SCROLL_LOCK = 0x91;
356+
357+ /** Constant for the F1 function key. */
358+ public static final int VK_F1 = 0x70;
359+
360+ /** Constant for the F2 function key. */
361+ public static final int VK_F2 = 0x71;
362+
363+ /** Constant for the F3 function key. */
364+ public static final int VK_F3 = 0x72;
365+
366+ /** Constant for the F4 function key. */
367+ public static final int VK_F4 = 0x73;
368+
369+ /** Constant for the F5 function key. */
370+ public static final int VK_F5 = 0x74;
371+
372+ /** Constant for the F6 function key. */
373+ public static final int VK_F6 = 0x75;
374+
375+ /** Constant for the F7 function key. */
376+ public static final int VK_F7 = 0x76;
377+
378+ /** Constant for the F8 function key. */
379+ public static final int VK_F8 = 0x77;
380+
381+ /** Constant for the F9 function key. */
382+ public static final int VK_F9 = 0x78;
383+
384+ /** Constant for the F10 function key. */
385+ public static final int VK_F10 = 0x79;
386+
387+ /** Constant for the F11 function key. */
388+ public static final int VK_F11 = 0x7A;
389+
390+ /** Constant for the F12 function key. */
391+ public static final int VK_F12 = 0x7B;
392+
393+ /**
394+ * Constant for the F13 function key.
395+ * @since 1.2
396+ */
397+ /* F13 - F24 are used on IBM 3270 keyboard; use random range for constants. */
398+ public static final int VK_F13 = 0xF000;
399+
400+ /**
401+ * Constant for the F14 function key.
402+ * @since 1.2
403+ */
404+ public static final int VK_F14 = 0xF001;
405+
406+ /**
407+ * Constant for the F15 function key.
408+ * @since 1.2
409+ */
410+ public static final int VK_F15 = 0xF002;
411+
412+ /**
413+ * Constant for the F16 function key.
414+ * @since 1.2
415+ */
416+ public static final int VK_F16 = 0xF003;
417+
418+ /**
419+ * Constant for the F17 function key.
420+ * @since 1.2
421+ */
422+ public static final int VK_F17 = 0xF004;
423+
424+ /**
425+ * Constant for the F18 function key.
426+ * @since 1.2
427+ */
428+ public static final int VK_F18 = 0xF005;
429+
430+ /**
431+ * Constant for the F19 function key.
432+ * @since 1.2
433+ */
434+ public static final int VK_F19 = 0xF006;
435+
436+ /**
437+ * Constant for the F20 function key.
438+ * @since 1.2
439+ */
440+ public static final int VK_F20 = 0xF007;
441+
442+ /**
443+ * Constant for the F21 function key.
444+ * @since 1.2
445+ */
446+ public static final int VK_F21 = 0xF008;
447+
448+ /**
449+ * Constant for the F22 function key.
450+ * @since 1.2
451+ */
452+ public static final int VK_F22 = 0xF009;
453+
454+ /**
455+ * Constant for the F23 function key.
456+ * @since 1.2
457+ */
458+ public static final int VK_F23 = 0xF00A;
459+
460+ /**
461+ * Constant for the F24 function key.
462+ * @since 1.2
463+ */
464+ public static final int VK_F24 = 0xF00B;
465+
466+ public static final int VK_PRINTSCREEN = 0x9A;
467+ public static final int VK_INSERT = 0x9B;
468+ public static final int VK_HELP = 0x9C;
469+ public static final int VK_META = 0x9D;
470+
471+ public static final int VK_BACK_QUOTE = 0xC0;
472+ public static final int VK_QUOTE = 0xDE;
473+
474+ /**
475+ * Constant for the numeric keypad <b>up</b> arrow key.
476+ * @see #VK_UP
477+ * @since 1.2
478+ */
479+ public static final int VK_KP_UP = 0xE0;
480+
481+ /**
482+ * Constant for the numeric keypad <b>down</b> arrow key.
483+ * @see #VK_DOWN
484+ * @since 1.2
485+ */
486+ public static final int VK_KP_DOWN = 0xE1;
487+
488+ /**
489+ * Constant for the numeric keypad <b>left</b> arrow key.
490+ * @see #VK_LEFT
491+ * @since 1.2
492+ */
493+ public static final int VK_KP_LEFT = 0xE2;
494+
495+ /**
496+ * Constant for the numeric keypad <b>right</b> arrow key.
497+ * @see #VK_RIGHT
498+ * @since 1.2
499+ */
500+ public static final int VK_KP_RIGHT = 0xE3;
501+
502+ /* For European keyboards */
503+ /** @since 1.2 */
504+ public static final int VK_DEAD_GRAVE = 0x80;
505+ /** @since 1.2 */
506+ public static final int VK_DEAD_ACUTE = 0x81;
507+ /** @since 1.2 */
508+ public static final int VK_DEAD_CIRCUMFLEX = 0x82;
509+ /** @since 1.2 */
510+ public static final int VK_DEAD_TILDE = 0x83;
511+ /** @since 1.2 */
512+ public static final int VK_DEAD_MACRON = 0x84;
513+ /** @since 1.2 */
514+ public static final int VK_DEAD_BREVE = 0x85;
515+ /** @since 1.2 */
516+ public static final int VK_DEAD_ABOVEDOT = 0x86;
517+ /** @since 1.2 */
518+ public static final int VK_DEAD_DIAERESIS = 0x87;
519+ /** @since 1.2 */
520+ public static final int VK_DEAD_ABOVERING = 0x88;
521+ /** @since 1.2 */
522+ public static final int VK_DEAD_DOUBLEACUTE = 0x89;
523+ /** @since 1.2 */
524+ public static final int VK_DEAD_CARON = 0x8a;
525+ /** @since 1.2 */
526+ public static final int VK_DEAD_CEDILLA = 0x8b;
527+ /** @since 1.2 */
528+ public static final int VK_DEAD_OGONEK = 0x8c;
529+ /** @since 1.2 */
530+ public static final int VK_DEAD_IOTA = 0x8d;
531+ /** @since 1.2 */
532+ public static final int VK_DEAD_VOICED_SOUND = 0x8e;
533+ /** @since 1.2 */
534+ public static final int VK_DEAD_SEMIVOICED_SOUND = 0x8f;
535+
536+ /** @since 1.2 */
537+ public static final int VK_AMPERSAND = 0x96;
538+ /** @since 1.2 */
539+ public static final int VK_ASTERISK = 0x97;
540+ /** @since 1.2 */
541+ public static final int VK_QUOTEDBL = 0x98;
542+ /** @since 1.2 */
543+ public static final int VK_LESS = 0x99;
544+
545+ /** @since 1.2 */
546+ public static final int VK_GREATER = 0xa0;
547+ /** @since 1.2 */
548+ public static final int VK_BRACELEFT = 0xa1;
549+ /** @since 1.2 */
550+ public static final int VK_BRACERIGHT = 0xa2;
551+
552+ /**
553+ * Constant for the "@" key.
554+ * @since 1.2
555+ */
556+ public static final int VK_AT = 0x0200;
557+
558+ /**
559+ * Constant for the ":" key.
560+ * @since 1.2
561+ */
562+ public static final int VK_COLON = 0x0201;
563+
564+ /**
565+ * Constant for the "^" key.
566+ * @since 1.2
567+ */
568+ public static final int VK_CIRCUMFLEX = 0x0202;
569+
570+ /**
571+ * Constant for the "$" key.
572+ * @since 1.2
573+ */
574+ public static final int VK_DOLLAR = 0x0203;
575+
576+ /**
577+ * Constant for the Euro currency sign key.
578+ * @since 1.2
579+ */
580+ public static final int VK_EURO_SIGN = 0x0204;
581+
582+ /**
583+ * Constant for the "!" key.
584+ * @since 1.2
585+ */
586+ public static final int VK_EXCLAMATION_MARK = 0x0205;
587+
588+ /**
589+ * Constant for the inverted exclamation mark key.
590+ * @since 1.2
591+ */
592+ public static final int VK_INVERTED_EXCLAMATION_MARK = 0x0206;
593+
594+ /**
595+ * Constant for the "(" key.
596+ * @since 1.2
597+ */
598+ public static final int VK_LEFT_PARENTHESIS = 0x0207;
599+
600+ /**
601+ * Constant for the "#" key.
602+ * @since 1.2
603+ */
604+ public static final int VK_NUMBER_SIGN = 0x0208;
605+
606+ /**
607+ * Constant for the "+" key.
608+ * @since 1.2
609+ */
610+ public static final int VK_PLUS = 0x0209;
611+
612+ /**
613+ * Constant for the ")" key.
614+ * @since 1.2
615+ */
616+ public static final int VK_RIGHT_PARENTHESIS = 0x020A;
617+
618+ /**
619+ * Constant for the "_" key.
620+ * @since 1.2
621+ */
622+ public static final int VK_UNDERSCORE = 0x020B;
623+
624+ /**
625+ * Constant for the Microsoft Windows "Windows" key.
626+ * It is used for both the left and right version of the key.
627+ * @see #getKeyLocation()
628+ * @since 1.5
629+ */
630+ public static final int VK_WINDOWS = 0x020C;
631+
632+ /**
633+ * Constant for the Microsoft Windows Context Menu key.
634+ * @since 1.5
635+ */
636+ public static final int VK_CONTEXT_MENU = 0x020D;
637+
638+ /* for input method support on Asian Keyboards */
639+
640+ /* not clear what this means - listed in Microsoft Windows API */
641+ public static final int VK_FINAL = 0x0018;
642+
643+ /** Constant for the Convert function key. */
644+ /* Japanese PC 106 keyboard, Japanese Solaris keyboard: henkan */
645+ public static final int VK_CONVERT = 0x001C;
646+
647+ /** Constant for the Don't Convert function key. */
648+ /* Japanese PC 106 keyboard: muhenkan */
649+ public static final int VK_NONCONVERT = 0x001D;
650+
651+ /** Constant for the Accept or Commit function key. */
652+ /* Japanese Solaris keyboard: kakutei */
653+ public static final int VK_ACCEPT = 0x001E;
654+
655+ /* not clear what this means - listed in Microsoft Windows API */
656+ public static final int VK_MODECHANGE = 0x001F;
657+
658+ /* replaced by VK_KANA_LOCK for Microsoft Windows and Solaris;
659+ might still be used on other platforms */
660+ public static final int VK_KANA = 0x0015;
661+
662+ /* replaced by VK_INPUT_METHOD_ON_OFF for Microsoft Windows and Solaris;
663+ might still be used for other platforms */
664+ public static final int VK_KANJI = 0x0019;
665+
666+ /**
667+ * Constant for the Alphanumeric function key.
668+ * @since 1.2
669+ */
670+ /* Japanese PC 106 keyboard: eisuu */
671+ public static final int VK_ALPHANUMERIC = 0x00F0;
672+
673+ /**
674+ * Constant for the Katakana function key.
675+ * @since 1.2
676+ */
677+ /* Japanese PC 106 keyboard: katakana */
678+ public static final int VK_KATAKANA = 0x00F1;
679+
680+ /**
681+ * Constant for the Hiragana function key.
682+ * @since 1.2
683+ */
684+ /* Japanese PC 106 keyboard: hiragana */
685+ public static final int VK_HIRAGANA = 0x00F2;
686+
687+ /**
688+ * Constant for the Full-Width Characters function key.
689+ * @since 1.2
690+ */
691+ /* Japanese PC 106 keyboard: zenkaku */
692+ public static final int VK_FULL_WIDTH = 0x00F3;
693+
694+ /**
695+ * Constant for the Half-Width Characters function key.
696+ * @since 1.2
697+ */
698+ /* Japanese PC 106 keyboard: hankaku */
699+ public static final int VK_HALF_WIDTH = 0x00F4;
700+
701+ /**
702+ * Constant for the Roman Characters function key.
703+ * @since 1.2
704+ */
705+ /* Japanese PC 106 keyboard: roumaji */
706+ public static final int VK_ROMAN_CHARACTERS = 0x00F5;
707+
708+ /**
709+ * Constant for the All Candidates function key.
710+ * @since 1.2
711+ */
712+ /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */
713+ public static final int VK_ALL_CANDIDATES = 0x0100;
714+
715+ /**
716+ * Constant for the Previous Candidate function key.
717+ * @since 1.2
718+ */
719+ /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */
720+ public static final int VK_PREVIOUS_CANDIDATE = 0x0101;
721+
722+ /**
723+ * Constant for the Code Input function key.
724+ * @since 1.2
725+ */
726+ /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */
727+ public static final int VK_CODE_INPUT = 0x0102;
728+
729+ /**
730+ * Constant for the Japanese-Katakana function key.
731+ * This key switches to a Japanese input method and selects its Katakana input mode.
732+ * @since 1.2
733+ */
734+ /* Japanese Macintosh keyboard - VK_JAPANESE_HIRAGANA + SHIFT */
735+ public static final int VK_JAPANESE_KATAKANA = 0x0103;
736+
737+ /**
738+ * Constant for the Japanese-Hiragana function key.
739+ * This key switches to a Japanese input method and selects its Hiragana input mode.
740+ * @since 1.2
741+ */
742+ /* Japanese Macintosh keyboard */
743+ public static final int VK_JAPANESE_HIRAGANA = 0x0104;
744+
745+ /**
746+ * Constant for the Japanese-Roman function key.
747+ * This key switches to a Japanese input method and selects its Roman-Direct input mode.
748+ * @since 1.2
749+ */
750+ /* Japanese Macintosh keyboard */
751+ public static final int VK_JAPANESE_ROMAN = 0x0105;
752+
753+ /**
754+ * Constant for the locking Kana function key.
755+ * This key locks the keyboard into a Kana layout.
756+ * @since 1.3
757+ */
758+ /* Japanese PC 106 keyboard with special Windows driver - eisuu + Control; Japanese Solaris keyboard: kana */
759+ public static final int VK_KANA_LOCK = 0x0106;
760+
761+ /**
762+ * Constant for the input method on/off key.
763+ * @since 1.3
764+ */
765+ /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */
766+ public static final int VK_INPUT_METHOD_ON_OFF = 0x0107;
767+
768+ /* for Sun keyboards */
769+ /** @since 1.2 */
770+ public static final int VK_CUT = 0xFFD1;
771+ /** @since 1.2 */
772+ public static final int VK_COPY = 0xFFCD;
773+ /** @since 1.2 */
774+ public static final int VK_PASTE = 0xFFCF;
775+ /** @since 1.2 */
776+ public static final int VK_UNDO = 0xFFCB;
777+ /** @since 1.2 */
778+ public static final int VK_AGAIN = 0xFFC9;
779+ /** @since 1.2 */
780+ public static final int VK_FIND = 0xFFD0;
781+ /** @since 1.2 */
782+ public static final int VK_PROPS = 0xFFCA;
783+ /** @since 1.2 */
784+ public static final int VK_STOP = 0xFFC8;
785+
786+ /**
787+ * Constant for the Compose function key.
788+ * @since 1.2
789+ */
790+ public static final int VK_COMPOSE = 0xFF20;
791+
792+ /**
793+ * Constant for the AltGraph function key.
794+ * @since 1.2
795+ */
796+ public static final int VK_ALT_GRAPH = 0xFF7E;
797+
798+ /**
799+ * Constant for the Begin key.
800+ * @since 1.5
801+ */
802+ public static final int VK_BEGIN = 0xFF58;
803+
804+ /**
805+ * This value is used to indicate that the keyCode is unknown.
806+ * KEY_TYPED events do not have a keyCode value; this value
807+ * is used instead.
808+ */
809+ public static final int VK_UNDEFINED = 0x0;
810+
811+ /**
812+ * KEY_PRESSED and KEY_RELEASED events which do not map to a
813+ * valid Unicode character use this for the keyChar value.
814+ */
815+ public static final char CHAR_UNDEFINED = 0xFFFF;
816+
817+ /**
818+ * A constant indicating that the keyLocation is indeterminate
819+ * or not relevant.
820+ * <code>KEY_TYPED</code> events do not have a keyLocation; this value
821+ * is used instead.
822+ * @since 1.4
823+ */
824+ public static final int KEY_LOCATION_UNKNOWN = 0;
825+
826+ /**
827+ * A constant indicating that the key pressed or released
828+ * is not distinguished as the left or right version of a key,
829+ * and did not originate on the numeric keypad (or did not
830+ * originate with a virtual key corresponding to the numeric
831+ * keypad).
832+ * @since 1.4
833+ */
834+ public static final int KEY_LOCATION_STANDARD = 1;
835+
836+ /**
837+ * A constant indicating that the key pressed or released is in
838+ * the left key location (there is more than one possible location
839+ * for this key). Example: the left shift key.
840+ * @since 1.4
841+ */
842+ public static final int KEY_LOCATION_LEFT = 2;
843+
844+ /**
845+ * A constant indicating that the key pressed or released is in
846+ * the right key location (there is more than one possible location
847+ * for this key). Example: the right shift key.
848+ * @since 1.4
849+ */
850+ public static final int KEY_LOCATION_RIGHT = 3;
851+
852+ /**
853+ * A constant indicating that the key event originated on the
854+ * numeric keypad or with a virtual key corresponding to the
855+ * numeric keypad.
856+ * @since 1.4
857+ */
858+ public static final int KEY_LOCATION_NUMPAD = 4;
859+
860+ /**
861+ * The unique value assigned to each of the keys on the
862+ * keyboard. There is a common set of key codes that
863+ * can be fired by most keyboards.
864+ * The symbolic name for a key code should be used rather
865+ * than the code value itself.
866+ *
867+ * @serial
868+ * @see #getKeyCode()
869+ * @see #setKeyCode(int)
870+ */
871+ int keyCode;
872+
873+ /**
874+ * <code>keyChar</code> is a valid unicode character
875+ * that is fired by a key or a key combination on
876+ * a keyboard.
877+ *
878+ * @serial
879+ * @see #getKeyChar()
880+ * @see #setKeyChar(char)
881+ */
882+ char keyChar;
883+
884+ /**
885+ * The location of the key on the keyboard.
886+ *
887+ * Some keys occur more than once on a keyboard, e.g. the left and
888+ * right shift keys. Additionally, some keys occur on the numeric
889+ * keypad. This variable is used to distinguish such keys.
890+ *
891+ * The only legal values are <code>KEY_LOCATION_UNKNOWN</code>,
892+ * <code>KEY_LOCATION_STANDARD</code>, <code>KEY_LOCATION_LEFT</code>,
893+ * <code>KEY_LOCATION_RIGHT</code>, and <code>KEY_LOCATION_NUMPAD</code>.
894+ *
895+ * @serial
896+ * @see #getKeyLocation()
897+ */
898+ int keyLocation;
899+
900+ //set from native code.
901+ private transient long rawCode = 0;
902+ private transient long primaryLevelUnicode = 0;
903+ private transient long scancode = 0; // for MS Windows only
904+ private transient long extendedKeyCode = 0;
905+
906+ /*
907+ * JDK 1.1 serialVersionUID
908+ */
909+ private static final long serialVersionUID = -2352130953028126954L;
910+
911+ static {
912+ /* ensure that the necessary native libraries are loaded */
913+ NativeLibLoader.loadLibraries();
914+ if (!GraphicsEnvironment.isHeadless()) {
915+ initIDs();
916+ }
917+ }
918+
919+ /**
920+ * Initialize JNI field and method IDs for fields that may be
921+ * accessed from C.
922+ */
923+ private static native void initIDs();
924+
925+ private KeyEvent(Component source, int id, long when, int modifiers,
926+ int keyCode, char keyChar, int keyLocation, boolean isProxyActive) {
927+ this(source, id, when, modifiers, keyCode, keyChar, keyLocation);
928+ this.isProxyActive = isProxyActive;
929+ }
930+
931+ /**
932+ * Constructs a <code>KeyEvent</code> object.
933+ * <p>This method throws an
934+ * <code>IllegalArgumentException</code> if <code>source</code>
935+ * is <code>null</code>.
936+ *
937+ * @param source The <code>Component</code> that originated the event
938+ * @param id An integer indicating the type of event.
939+ * For information on allowable values, see
940+ * the class description for {@link KeyEvent}
941+ * @param when A long integer that specifies the time the event
942+ * occurred.
943+ * Passing negative or zero value
944+ * is not recommended
945+ * @param modifiers The modifier keys down during event (shift, ctrl,
946+ * alt, meta).
947+ * Passing negative value
948+ * is not recommended.
949+ * Zero value means that no modifiers were passed.
950+ * Use either an extended _DOWN_MASK or old _MASK modifiers,
951+ * however do not mix models in the one event.
952+ * The extended modifiers are preferred for using
953+ * @param keyCode The integer code for an actual key, or VK_UNDEFINED
954+ * (for a key-typed event)
955+ * @param keyChar The Unicode character generated by this event, or
956+ * CHAR_UNDEFINED (for key-pressed and key-released
957+ * events which do not map to a valid Unicode character)
958+ * @param keyLocation Identifies the key location. The only legal
959+ * values are <code>KEY_LOCATION_UNKNOWN</code>,
960+ * <code>KEY_LOCATION_STANDARD</code>, <code>KEY_LOCATION_LEFT</code>,
961+ * <code>KEY_LOCATION_RIGHT</code>, and <code>KEY_LOCATION_NUMPAD</code>.
962+ * @throws IllegalArgumentException
963+ * if <code>id</code> is <code>KEY_TYPED</code> and
964+ * <code>keyChar</code> is <code>CHAR_UNDEFINED</code>;
965+ * or if <code>id</code> is <code>KEY_TYPED</code> and
966+ * <code>keyCode</code> is not <code>VK_UNDEFINED</code>;
967+ * or if <code>id</code> is <code>KEY_TYPED</code> and
968+ * <code>keyLocation</code> is not <code>KEY_LOCATION_UNKNOWN</code>;
969+ * or if <code>keyLocation</code> is not one of the legal
970+ * values enumerated above.
971+ * @throws IllegalArgumentException if <code>source</code> is null
972+ * @see #getSource()
973+ * @see #getID()
974+ * @see #getWhen()
975+ * @see #getModifiers()
976+ * @see #getKeyCode()
977+ * @see #getKeyChar()
978+ * @see #getKeyLocation()
979+ * @since 1.4
980+ */
981+ public KeyEvent(Component source, int id, long when, int modifiers,
982+ int keyCode, char keyChar, int keyLocation) {
983+ super(source, id, when, modifiers);
984+ if (id == KEY_TYPED) {
985+ if (keyChar == CHAR_UNDEFINED) {
986+ throw new IllegalArgumentException("invalid keyChar");
987+ }
988+ if (keyCode != VK_UNDEFINED) {
989+ throw new IllegalArgumentException("invalid keyCode");
990+ }
991+ if (keyLocation != KEY_LOCATION_UNKNOWN) {
992+ throw new IllegalArgumentException("invalid keyLocation");
993+ }
994+ }
995+
996+ this.keyCode = keyCode;
997+ this.keyChar = keyChar;
998+
999+ if ((keyLocation < KEY_LOCATION_UNKNOWN) ||
1000+ (keyLocation > KEY_LOCATION_NUMPAD)) {
1001+ throw new IllegalArgumentException("invalid keyLocation");
1002+ }
1003+ this.keyLocation = keyLocation;
1004+ if ((getModifiers() != 0) && (getModifiersEx() == 0)) {
1005+ setNewModifiers();
1006+ } else if ((getModifiers() == 0) && (getModifiersEx() != 0)) {
1007+ setOldModifiers();
1008+ }
1009+ }
1010+
1011+ /**
1012+ * Constructs a <code>KeyEvent</code> object.
1013+ * <p> This method throws an
1014+ * <code>IllegalArgumentException</code> if <code>source</code>
1015+ * is <code>null</code>.
1016+ *
1017+ * @param source The <code>Component</code> that originated the event
1018+ * @param id An integer indicating the type of event.
1019+ * For information on allowable values, see
1020+ * the class description for {@link KeyEvent}
1021+ * @param when A long integer that specifies the time the event
1022+ * occurred.
1023+ * Passing negative or zero value
1024+ * is not recommended
1025+ * @param modifiers The modifier keys down during event (shift, ctrl,
1026+ * alt, meta).
1027+ * Passing negative value
1028+ * is not recommended.
1029+ * Zero value means that no modifiers were passed.
1030+ * Use either an extended _DOWN_MASK or old _MASK modifiers,
1031+ * however do not mix models in the one event.
1032+ * The extended modifiers are preferred for using
1033+ * @param keyCode The integer code for an actual key, or VK_UNDEFINED
1034+ * (for a key-typed event)
1035+ * @param keyChar The Unicode character generated by this event, or
1036+ * CHAR_UNDEFINED (for key-pressed and key-released
1037+ * events which do not map to a valid Unicode character)
1038+ * @throws IllegalArgumentException if <code>id</code> is
1039+ * <code>KEY_TYPED</code> and <code>keyChar</code> is
1040+ * <code>CHAR_UNDEFINED</code>; or if <code>id</code> is
1041+ * <code>KEY_TYPED</code> and <code>keyCode</code> is not
1042+ * <code>VK_UNDEFINED</code>
1043+ * @throws IllegalArgumentException if <code>source</code> is null
1044+ * @see #getSource()
1045+ * @see #getID()
1046+ * @see #getWhen()
1047+ * @see #getModifiers()
1048+ * @see #getKeyCode()
1049+ * @see #getKeyChar()
1050+ */
1051+ public KeyEvent(Component source, int id, long when, int modifiers,
1052+ int keyCode, char keyChar) {
1053+ this(source, id, when, modifiers, keyCode, keyChar,
1054+ KEY_LOCATION_UNKNOWN);
1055+ }
1056+
1057+ /**
1058+ * @deprecated as of JDK1.1
1059+ */
1060+ @Deprecated
1061+ public KeyEvent(Component source, int id, long when, int modifiers,
1062+ int keyCode) {
1063+ this(source, id, when, modifiers, keyCode, (char)keyCode);
1064+ }
1065+
1066+ /**
1067+ * Returns the integer keyCode associated with the key in this event.
1068+ *
1069+ * @return the integer code for an actual key on the keyboard.
1070+ * (For <code>KEY_TYPED</code> events, the keyCode is
1071+ * <code>VK_UNDEFINED</code>.)
1072+ */
1073+ public int getKeyCode() {
1074+ return keyCode;
1075+ }
1076+
1077+ /**
1078+ * Set the keyCode value to indicate a physical key.
1079+ *
1080+ * @param keyCode an integer corresponding to an actual key on the keyboard.
1081+ */
1082+ public void setKeyCode(int keyCode) {
1083+ this.keyCode = keyCode;
1084+ }
1085+
1086+ /**
1087+ * Returns the character associated with the key in this event.
1088+ * For example, the <code>KEY_TYPED</code> event for shift + "a"
1089+ * returns the value for "A".
1090+ * <p>
1091+ * <code>KEY_PRESSED</code> and <code>KEY_RELEASED</code> events
1092+ * are not intended for reporting of character input. Therefore,
1093+ * the values returned by this method are guaranteed to be
1094+ * meaningful only for <code>KEY_TYPED</code> events.
1095+ *
1096+ * @return the Unicode character defined for this key event.
1097+ * If no valid Unicode character exists for this key event,
1098+ * <code>CHAR_UNDEFINED</code> is returned.
1099+ */
1100+ public char getKeyChar() {
1101+ return keyChar;
1102+ }
1103+
1104+ /**
1105+ * Set the keyChar value to indicate a logical character.
1106+ *
1107+ * @param keyChar a char corresponding to to the combination of keystrokes
1108+ * that make up this event.
1109+ */
1110+ public void setKeyChar(char keyChar) {
1111+ this.keyChar = keyChar;
1112+ }
1113+
1114+ /**
1115+ * Set the modifiers to indicate additional keys that were held down
1116+ * (e.g. shift, ctrl, alt, meta) defined as part of InputEvent.
1117+ * <p>
1118+ * NOTE: use of this method is not recommended, because many AWT
1119+ * implementations do not recognize modifier changes. This is
1120+ * especially true for <code>KEY_TYPED</code> events where the shift
1121+ * modifier is changed.
1122+ *
1123+ * @param modifiers an integer combination of the modifier constants.
1124+ * @see InputEvent
1125+ * @deprecated as of JDK1.1.4
1126+ */
1127+ @Deprecated
1128+ public void setModifiers(int modifiers) {
1129+ this.modifiers = modifiers;
1130+ if ((getModifiers() != 0) && (getModifiersEx() == 0)) {
1131+ setNewModifiers();
1132+ } else if ((getModifiers() == 0) && (getModifiersEx() != 0)) {
1133+ setOldModifiers();
1134+ }
1135+ }
1136+
1137+ /**
1138+ * Returns the location of the key that originated this key event.
1139+ *
1140+ * Some keys occur more than once on a keyboard, e.g. the left and
1141+ * right shift keys. Additionally, some keys occur on the numeric
1142+ * keypad. This provides a way of distinguishing such keys.
1143+ *
1144+ * @return the location of the key that was pressed or released.
1145+ * Always returns <code>KEY_LOCATION_UNKNOWN</code> for
1146+ * <code>KEY_TYPED</code> events.
1147+ * @since 1.4
1148+ */
1149+ public int getKeyLocation() {
1150+ return keyLocation;
1151+ }
1152+
1153+ /**
1154+ * Returns a String describing the keyCode, such as "HOME", "F1" or "A".
1155+ * These strings can be localized by changing the awt.properties file.
1156+ *
1157+ * @return a string containing a text description for a physical key,
1158+ * identified by its keyCode
1159+ */
1160+ public static String getKeyText(int keyCode) {
1161+ if (keyCode >= VK_0 && keyCode <= VK_9 ||
1162+ keyCode >= VK_A && keyCode <= VK_Z) {
1163+ return String.valueOf((char)keyCode);
1164+ }
1165+
1166+ switch(keyCode) {
1167+ case VK_ENTER: return Toolkit.getProperty("AWT.enter", "Enter");
1168+ case VK_BACK_SPACE: return Toolkit.getProperty("AWT.backSpace", "Backspace");
1169+ case VK_TAB: return Toolkit.getProperty("AWT.tab", "Tab");
1170+ case VK_CANCEL: return Toolkit.getProperty("AWT.cancel", "Cancel");
1171+ case VK_CLEAR: return Toolkit.getProperty("AWT.clear", "Clear");
1172+ case VK_COMPOSE: return Toolkit.getProperty("AWT.compose", "Compose");
1173+ case VK_PAUSE: return Toolkit.getProperty("AWT.pause", "Pause");
1174+ case VK_CAPS_LOCK: return Toolkit.getProperty("AWT.capsLock", "Caps Lock");
1175+ case VK_ESCAPE: return Toolkit.getProperty("AWT.escape", "Escape");
1176+ case VK_SPACE: return Toolkit.getProperty("AWT.space", "Space");
1177+ case VK_PAGE_UP: return Toolkit.getProperty("AWT.pgup", "Page Up");
1178+ case VK_PAGE_DOWN: return Toolkit.getProperty("AWT.pgdn", "Page Down");
1179+ case VK_END: return Toolkit.getProperty("AWT.end", "End");
1180+ case VK_HOME: return Toolkit.getProperty("AWT.home", "Home");
1181+ case VK_LEFT: return Toolkit.getProperty("AWT.left", "Left");
1182+ case VK_UP: return Toolkit.getProperty("AWT.up", "Up");
1183+ case VK_RIGHT: return Toolkit.getProperty("AWT.right", "Right");
1184+ case VK_DOWN: return Toolkit.getProperty("AWT.down", "Down");
1185+ case VK_BEGIN: return Toolkit.getProperty("AWT.begin", "Begin");
1186+
1187+ // modifiers
1188+ case VK_SHIFT: return Toolkit.getProperty("AWT.shift", "Shift");
1189+ case VK_CONTROL: return Toolkit.getProperty("AWT.control", "Control");
1190+ case VK_ALT: return Toolkit.getProperty("AWT.alt", "Alt");
1191+ case VK_META: return Toolkit.getProperty("AWT.meta", "Meta");
1192+ case VK_ALT_GRAPH: return Toolkit.getProperty("AWT.altGraph", "Alt Graph");
1193+
1194+ // punctuation
1195+ case VK_COMMA: return Toolkit.getProperty("AWT.comma", "Comma");
1196+ case VK_PERIOD: return Toolkit.getProperty("AWT.period", "Period");
1197+ case VK_SLASH: return Toolkit.getProperty("AWT.slash", "Slash");
1198+ case VK_SEMICOLON: return Toolkit.getProperty("AWT.semicolon", "Semicolon");
1199+ case VK_EQUALS: return Toolkit.getProperty("AWT.equals", "Equals");
1200+ case VK_OPEN_BRACKET: return Toolkit.getProperty("AWT.openBracket", "Open Bracket");
1201+ case VK_BACK_SLASH: return Toolkit.getProperty("AWT.backSlash", "Back Slash");
1202+ case VK_CLOSE_BRACKET: return Toolkit.getProperty("AWT.closeBracket", "Close Bracket");
1203+
1204+ // numpad numeric keys handled below
1205+ case VK_MULTIPLY: return Toolkit.getProperty("AWT.multiply", "NumPad *");
1206+ case VK_ADD: return Toolkit.getProperty("AWT.add", "NumPad +");
1207+ case VK_SEPARATOR: return Toolkit.getProperty("AWT.separator", "NumPad ,");
1208+ case VK_SUBTRACT: return Toolkit.getProperty("AWT.subtract", "NumPad -");
1209+ case VK_DECIMAL: return Toolkit.getProperty("AWT.decimal", "NumPad .");
1210+ case VK_DIVIDE: return Toolkit.getProperty("AWT.divide", "NumPad /");
1211+ case VK_DELETE: return Toolkit.getProperty("AWT.delete", "Delete");
1212+ case VK_NUM_LOCK: return Toolkit.getProperty("AWT.numLock", "Num Lock");
1213+ case VK_SCROLL_LOCK: return Toolkit.getProperty("AWT.scrollLock", "Scroll Lock");
1214+
1215+ case VK_WINDOWS: return Toolkit.getProperty("AWT.windows", "Windows");
1216+ case VK_CONTEXT_MENU: return Toolkit.getProperty("AWT.context", "Context Menu");
1217+
1218+ case VK_F1: return Toolkit.getProperty("AWT.f1", "F1");
1219+ case VK_F2: return Toolkit.getProperty("AWT.f2", "F2");
1220+ case VK_F3: return Toolkit.getProperty("AWT.f3", "F3");
1221+ case VK_F4: return Toolkit.getProperty("AWT.f4", "F4");
1222+ case VK_F5: return Toolkit.getProperty("AWT.f5", "F5");
1223+ case VK_F6: return Toolkit.getProperty("AWT.f6", "F6");
1224+ case VK_F7: return Toolkit.getProperty("AWT.f7", "F7");
1225+ case VK_F8: return Toolkit.getProperty("AWT.f8", "F8");
1226+ case VK_F9: return Toolkit.getProperty("AWT.f9", "F9");
1227+ case VK_F10: return Toolkit.getProperty("AWT.f10", "F10");
1228+ case VK_F11: return Toolkit.getProperty("AWT.f11", "F11");
1229+ case VK_F12: return Toolkit.getProperty("AWT.f12", "F12");
1230+ case VK_F13: return Toolkit.getProperty("AWT.f13", "F13");
1231+ case VK_F14: return Toolkit.getProperty("AWT.f14", "F14");
1232+ case VK_F15: return Toolkit.getProperty("AWT.f15", "F15");
1233+ case VK_F16: return Toolkit.getProperty("AWT.f16", "F16");
1234+ case VK_F17: return Toolkit.getProperty("AWT.f17", "F17");
1235+ case VK_F18: return Toolkit.getProperty("AWT.f18", "F18");
1236+ case VK_F19: return Toolkit.getProperty("AWT.f19", "F19");
1237+ case VK_F20: return Toolkit.getProperty("AWT.f20", "F20");
1238+ case VK_F21: return Toolkit.getProperty("AWT.f21", "F21");
1239+ case VK_F22: return Toolkit.getProperty("AWT.f22", "F22");
1240+ case VK_F23: return Toolkit.getProperty("AWT.f23", "F23");
1241+ case VK_F24: return Toolkit.getProperty("AWT.f24", "F24");
1242+
1243+ case VK_PRINTSCREEN: return Toolkit.getProperty("AWT.printScreen", "Print Screen");
1244+ case VK_INSERT: return Toolkit.getProperty("AWT.insert", "Insert");
1245+ case VK_HELP: return Toolkit.getProperty("AWT.help", "Help");
1246+ case VK_BACK_QUOTE: return Toolkit.getProperty("AWT.backQuote", "Back Quote");
1247+ case VK_QUOTE: return Toolkit.getProperty("AWT.quote", "Quote");
1248+
1249+ case VK_KP_UP: return Toolkit.getProperty("AWT.up", "Up");
1250+ case VK_KP_DOWN: return Toolkit.getProperty("AWT.down", "Down");
1251+ case VK_KP_LEFT: return Toolkit.getProperty("AWT.left", "Left");
1252+ case VK_KP_RIGHT: return Toolkit.getProperty("AWT.right", "Right");
1253+
1254+ case VK_DEAD_GRAVE: return Toolkit.getProperty("AWT.deadGrave", "Dead Grave");
1255+ case VK_DEAD_ACUTE: return Toolkit.getProperty("AWT.deadAcute", "Dead Acute");
1256+ case VK_DEAD_CIRCUMFLEX: return Toolkit.getProperty("AWT.deadCircumflex", "Dead Circumflex");
1257+ case VK_DEAD_TILDE: return Toolkit.getProperty("AWT.deadTilde", "Dead Tilde");
1258+ case VK_DEAD_MACRON: return Toolkit.getProperty("AWT.deadMacron", "Dead Macron");
1259+ case VK_DEAD_BREVE: return Toolkit.getProperty("AWT.deadBreve", "Dead Breve");
1260+ case VK_DEAD_ABOVEDOT: return Toolkit.getProperty("AWT.deadAboveDot", "Dead Above Dot");
1261+ case VK_DEAD_DIAERESIS: return Toolkit.getProperty("AWT.deadDiaeresis", "Dead Diaeresis");
1262+ case VK_DEAD_ABOVERING: return Toolkit.getProperty("AWT.deadAboveRing", "Dead Above Ring");
1263+ case VK_DEAD_DOUBLEACUTE: return Toolkit.getProperty("AWT.deadDoubleAcute", "Dead Double Acute");
1264+ case VK_DEAD_CARON: return Toolkit.getProperty("AWT.deadCaron", "Dead Caron");
1265+ case VK_DEAD_CEDILLA: return Toolkit.getProperty("AWT.deadCedilla", "Dead Cedilla");
1266+ case VK_DEAD_OGONEK: return Toolkit.getProperty("AWT.deadOgonek", "Dead Ogonek");
1267+ case VK_DEAD_IOTA: return Toolkit.getProperty("AWT.deadIota", "Dead Iota");
1268+ case VK_DEAD_VOICED_SOUND: return Toolkit.getProperty("AWT.deadVoicedSound", "Dead Voiced Sound");
1269+ case VK_DEAD_SEMIVOICED_SOUND: return Toolkit.getProperty("AWT.deadSemivoicedSound", "Dead Semivoiced Sound");
1270+
1271+ case VK_AMPERSAND: return Toolkit.getProperty("AWT.ampersand", "Ampersand");
1272+ case VK_ASTERISK: return Toolkit.getProperty("AWT.asterisk", "Asterisk");
1273+ case VK_QUOTEDBL: return Toolkit.getProperty("AWT.quoteDbl", "Double Quote");
1274+ case VK_LESS: return Toolkit.getProperty("AWT.Less", "Less");
1275+ case VK_GREATER: return Toolkit.getProperty("AWT.greater", "Greater");
1276+ case VK_BRACELEFT: return Toolkit.getProperty("AWT.braceLeft", "Left Brace");
1277+ case VK_BRACERIGHT: return Toolkit.getProperty("AWT.braceRight", "Right Brace");
1278+ case VK_AT: return Toolkit.getProperty("AWT.at", "At");
1279+ case VK_COLON: return Toolkit.getProperty("AWT.colon", "Colon");
1280+ case VK_CIRCUMFLEX: return Toolkit.getProperty("AWT.circumflex", "Circumflex");
1281+ case VK_DOLLAR: return Toolkit.getProperty("AWT.dollar", "Dollar");
1282+ case VK_EURO_SIGN: return Toolkit.getProperty("AWT.euro", "Euro");
1283+ case VK_EXCLAMATION_MARK: return Toolkit.getProperty("AWT.exclamationMark", "Exclamation Mark");
1284+ case VK_INVERTED_EXCLAMATION_MARK: return Toolkit.getProperty("AWT.invertedExclamationMark", "Inverted Exclamation Mark");
1285+ case VK_LEFT_PARENTHESIS: return Toolkit.getProperty("AWT.leftParenthesis", "Left Parenthesis");
1286+ case VK_NUMBER_SIGN: return Toolkit.getProperty("AWT.numberSign", "Number Sign");
1287+ case VK_MINUS: return Toolkit.getProperty("AWT.minus", "Minus");
1288+ case VK_PLUS: return Toolkit.getProperty("AWT.plus", "Plus");
1289+ case VK_RIGHT_PARENTHESIS: return Toolkit.getProperty("AWT.rightParenthesis", "Right Parenthesis");
1290+ case VK_UNDERSCORE: return Toolkit.getProperty("AWT.underscore", "Underscore");
1291+
1292+ case VK_FINAL: return Toolkit.getProperty("AWT.final", "Final");
1293+ case VK_CONVERT: return Toolkit.getProperty("AWT.convert", "Convert");
1294+ case VK_NONCONVERT: return Toolkit.getProperty("AWT.noconvert", "No Convert");
1295+ case VK_ACCEPT: return Toolkit.getProperty("AWT.accept", "Accept");
1296+ case VK_MODECHANGE: return Toolkit.getProperty("AWT.modechange", "Mode Change");
1297+ case VK_KANA: return Toolkit.getProperty("AWT.kana", "Kana");
1298+ case VK_KANJI: return Toolkit.getProperty("AWT.kanji", "Kanji");
1299+ case VK_ALPHANUMERIC: return Toolkit.getProperty("AWT.alphanumeric", "Alphanumeric");
1300+ case VK_KATAKANA: return Toolkit.getProperty("AWT.katakana", "Katakana");
1301+ case VK_HIRAGANA: return Toolkit.getProperty("AWT.hiragana", "Hiragana");
1302+ case VK_FULL_WIDTH: return Toolkit.getProperty("AWT.fullWidth", "Full-Width");
1303+ case VK_HALF_WIDTH: return Toolkit.getProperty("AWT.halfWidth", "Half-Width");
1304+ case VK_ROMAN_CHARACTERS: return Toolkit.getProperty("AWT.romanCharacters", "Roman Characters");
1305+ case VK_ALL_CANDIDATES: return Toolkit.getProperty("AWT.allCandidates", "All Candidates");
1306+ case VK_PREVIOUS_CANDIDATE: return Toolkit.getProperty("AWT.previousCandidate", "Previous Candidate");
1307+ case VK_CODE_INPUT: return Toolkit.getProperty("AWT.codeInput", "Code Input");
1308+ case VK_JAPANESE_KATAKANA: return Toolkit.getProperty("AWT.japaneseKatakana", "Japanese Katakana");
1309+ case VK_JAPANESE_HIRAGANA: return Toolkit.getProperty("AWT.japaneseHiragana", "Japanese Hiragana");
1310+ case VK_JAPANESE_ROMAN: return Toolkit.getProperty("AWT.japaneseRoman", "Japanese Roman");
1311+ case VK_KANA_LOCK: return Toolkit.getProperty("AWT.kanaLock", "Kana Lock");
1312+ case VK_INPUT_METHOD_ON_OFF: return Toolkit.getProperty("AWT.inputMethodOnOff", "Input Method On/Off");
1313+
1314+ case VK_AGAIN: return Toolkit.getProperty("AWT.again", "Again");
1315+ case VK_UNDO: return Toolkit.getProperty("AWT.undo", "Undo");
1316+ case VK_COPY: return Toolkit.getProperty("AWT.copy", "Copy");
1317+ case VK_PASTE: return Toolkit.getProperty("AWT.paste", "Paste");
1318+ case VK_CUT: return Toolkit.getProperty("AWT.cut", "Cut");
1319+ case VK_FIND: return Toolkit.getProperty("AWT.find", "Find");
1320+ case VK_PROPS: return Toolkit.getProperty("AWT.props", "Props");
1321+ case VK_STOP: return Toolkit.getProperty("AWT.stop", "Stop");
1322+ }
1323+
1324+ if (keyCode >= VK_NUMPAD0 && keyCode <= VK_NUMPAD9) {
1325+ String numpad = Toolkit.getProperty("AWT.numpad", "NumPad");
1326+ char c = (char)(keyCode - VK_NUMPAD0 + '0');
1327+ return numpad + "-" + c;
1328+ }
1329+
1330+ if ((keyCode & 0x01000000) != 0) {
1331+ return String.valueOf((char)(keyCode ^ 0x01000000 ));
1332+ }
1333+ String unknown = Toolkit.getProperty("AWT.unknown", "Unknown");
1334+ return unknown + " keyCode: 0x" + Integer.toString(keyCode, 16);
1335+ }
1336+
1337+ /**
1338+ * Returns a <code>String</code> describing the modifier key(s),
1339+ * such as "Shift", or "Ctrl+Shift". These strings can be
1340+ * localized by changing the <code>awt.properties</code> file.
1341+ * <p>
1342+ * Note that <code>InputEvent.ALT_MASK</code> and
1343+ * <code>InputEvent.BUTTON2_MASK</code> have the same value,
1344+ * so the string "Alt" is returned for both modifiers. Likewise,
1345+ * <code>InputEvent.META_MASK</code> and
1346+ * <code>InputEvent.BUTTON3_MASK</code> have the same value,
1347+ * so the string "Meta" is returned for both modifiers.
1348+ *
1349+ * @return string a text description of the combination of modifier
1350+ * keys that were held down during the event
1351+ * @see InputEvent#getModifiersExText(int)
1352+ */
1353+ public static String getKeyModifiersText(int modifiers) {
1354+ StringBuilder buf = new StringBuilder();
1355+ if ((modifiers & InputEvent.META_MASK) != 0) {
1356+ buf.append(Toolkit.getProperty("AWT.meta", "Meta"));
1357+ buf.append("+");
1358+ }
1359+ if ((modifiers & InputEvent.CTRL_MASK) != 0) {
1360+ buf.append(Toolkit.getProperty("AWT.control", "Ctrl"));
1361+ buf.append("+");
1362+ }
1363+ if ((modifiers & InputEvent.ALT_MASK) != 0) {
1364+ buf.append(Toolkit.getProperty("AWT.alt", "Alt"));
1365+ buf.append("+");
1366+ }
1367+ if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
1368+ buf.append(Toolkit.getProperty("AWT.shift", "Shift"));
1369+ buf.append("+");
1370+ }
1371+ if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
1372+ buf.append(Toolkit.getProperty("AWT.altGraph", "Alt Graph"));
1373+ buf.append("+");
1374+ }
1375+ if ((modifiers & InputEvent.BUTTON1_MASK) != 0) {
1376+ buf.append(Toolkit.getProperty("AWT.button1", "Button1"));
1377+ buf.append("+");
1378+ }
1379+ if (buf.length() > 0) {
1380+ buf.setLength(buf.length()-1); // remove trailing '+'
1381+ }
1382+ return buf.toString();
1383+ }
1384+
1385+
1386+ /**
1387+ * Returns whether the key in this event is an "action" key.
1388+ * Typically an action key does not fire a unicode character and is
1389+ * not a modifier key.
1390+ *
1391+ * @return <code>true</code> if the key is an "action" key,
1392+ * <code>false</code> otherwise
1393+ */
1394+ public boolean isActionKey() {
1395+ switch (keyCode) {
1396+ case VK_HOME:
1397+ case VK_END:
1398+ case VK_PAGE_UP:
1399+ case VK_PAGE_DOWN:
1400+ case VK_UP:
1401+ case VK_DOWN:
1402+ case VK_LEFT:
1403+ case VK_RIGHT:
1404+ case VK_BEGIN:
1405+
1406+ case VK_KP_LEFT:
1407+ case VK_KP_UP:
1408+ case VK_KP_RIGHT:
1409+ case VK_KP_DOWN:
1410+
1411+ case VK_F1:
1412+ case VK_F2:
1413+ case VK_F3:
1414+ case VK_F4:
1415+ case VK_F5:
1416+ case VK_F6:
1417+ case VK_F7:
1418+ case VK_F8:
1419+ case VK_F9:
1420+ case VK_F10:
1421+ case VK_F11:
1422+ case VK_F12:
1423+ case VK_F13:
1424+ case VK_F14:
1425+ case VK_F15:
1426+ case VK_F16:
1427+ case VK_F17:
1428+ case VK_F18:
1429+ case VK_F19:
1430+ case VK_F20:
1431+ case VK_F21:
1432+ case VK_F22:
1433+ case VK_F23:
1434+ case VK_F24:
1435+ case VK_PRINTSCREEN:
1436+ case VK_SCROLL_LOCK:
1437+ case VK_CAPS_LOCK:
1438+ case VK_NUM_LOCK:
1439+ case VK_PAUSE:
1440+ case VK_INSERT:
1441+
1442+ case VK_FINAL:
1443+ case VK_CONVERT:
1444+ case VK_NONCONVERT:
1445+ case VK_ACCEPT:
1446+ case VK_MODECHANGE:
1447+ case VK_KANA:
1448+ case VK_KANJI:
1449+ case VK_ALPHANUMERIC:
1450+ case VK_KATAKANA:
1451+ case VK_HIRAGANA:
1452+ case VK_FULL_WIDTH:
1453+ case VK_HALF_WIDTH:
1454+ case VK_ROMAN_CHARACTERS:
1455+ case VK_ALL_CANDIDATES:
1456+ case VK_PREVIOUS_CANDIDATE:
1457+ case VK_CODE_INPUT:
1458+ case VK_JAPANESE_KATAKANA:
1459+ case VK_JAPANESE_HIRAGANA:
1460+ case VK_JAPANESE_ROMAN:
1461+ case VK_KANA_LOCK:
1462+ case VK_INPUT_METHOD_ON_OFF:
1463+
1464+ case VK_AGAIN:
1465+ case VK_UNDO:
1466+ case VK_COPY:
1467+ case VK_PASTE:
1468+ case VK_CUT:
1469+ case VK_FIND:
1470+ case VK_PROPS:
1471+ case VK_STOP:
1472+
1473+ case VK_HELP:
1474+ case VK_WINDOWS:
1475+ case VK_CONTEXT_MENU:
1476+ return true;
1477+ }
1478+ return false;
1479+ }
1480+
1481+ /**
1482+ * Returns a parameter string identifying this event.
1483+ * This method is useful for event logging and for debugging.
1484+ *
1485+ * @return a string identifying the event and its attributes
1486+ */
1487+ public String paramString() {
1488+ StringBuilder str = new StringBuilder(100);
1489+
1490+ switch (id) {
1491+ case KEY_PRESSED:
1492+ str.append("KEY_PRESSED");
1493+ break;
1494+ case KEY_RELEASED:
1495+ str.append("KEY_RELEASED");
1496+ break;
1497+ case KEY_TYPED:
1498+ str.append("KEY_TYPED");
1499+ break;
1500+ default:
1501+ str.append("unknown type");
1502+ break;
1503+ }
1504+
1505+ str.append(",keyCode=").append(keyCode);
1506+ str.append(",keyText=").append(getKeyText(keyCode));
1507+
1508+ /* Some keychars don't print well, e.g. escape, backspace,
1509+ * tab, return, delete, cancel. Get keyText for the keyCode
1510+ * instead of the keyChar.
1511+ */
1512+ str.append(",keyChar=");
1513+ switch (keyChar) {
1514+ case '\b':
1515+ str.append(getKeyText(VK_BACK_SPACE));
1516+ break;
1517+ case '\t':
1518+ str.append(getKeyText(VK_TAB));
1519+ break;
1520+ case '\n':
1521+ str.append(getKeyText(VK_ENTER));
1522+ break;
1523+ case '\u0018':
1524+ str.append(getKeyText(VK_CANCEL));
1525+ break;
1526+ case '\u001b':
1527+ str.append(getKeyText(VK_ESCAPE));
1528+ break;
1529+ case '\u007f':
1530+ str.append(getKeyText(VK_DELETE));
1531+ break;
1532+ case CHAR_UNDEFINED:
1533+ str.append(Toolkit.getProperty("AWT.undefined", "Undefined"));
1534+ str.append(" keyChar");
1535+ break;
1536+ default:
1537+ str.append("'").append(keyChar).append("'");
1538+ break;
1539+ }
1540+
1541+ if (getModifiers() != 0) {
1542+ str.append(",modifiers=").append(getKeyModifiersText(modifiers));
1543+ }
1544+ if (getModifiersEx() != 0) {
1545+ str.append(",extModifiers=").append(getModifiersExText(modifiers));
1546+ }
1547+
1548+ str.append(",keyLocation=");
1549+ switch (keyLocation) {
1550+ case KEY_LOCATION_UNKNOWN:
1551+ str.append("KEY_LOCATION_UNKNOWN");
1552+ break;
1553+ case KEY_LOCATION_STANDARD:
1554+ str.append("KEY_LOCATION_STANDARD");
1555+ break;
1556+ case KEY_LOCATION_LEFT:
1557+ str.append("KEY_LOCATION_LEFT");
1558+ break;
1559+ case KEY_LOCATION_RIGHT:
1560+ str.append("KEY_LOCATION_RIGHT");
1561+ break;
1562+ case KEY_LOCATION_NUMPAD:
1563+ str.append("KEY_LOCATION_NUMPAD");
1564+ break;
1565+ default:
1566+ str.append("KEY_LOCATION_UNKNOWN");
1567+ break;
1568+ }
1569+ str.append(",rawCode=").append(rawCode);
1570+ str.append(",primaryLevelUnicode=").append(primaryLevelUnicode);
1571+ str.append(",scancode=").append(scancode);
1572+ str.append(",extendedKeyCode=0x").append(Long.toHexString(extendedKeyCode));
1573+
1574+ return str.toString();
1575+ }
1576+ /**
1577+ * Returns an extended key code for the event.
1578+ * The extended key code is a unique id assigned to a key on the keyboard
1579+ * just like {@code keyCode}. However, unlike {@code keyCode}, this value depends on the
1580+ * current keyboard layout. For instance, pressing the left topmost letter key
1581+ * in a common English layout produces the same value as {@code keyCode}, {@code VK_Q}.
1582+ * Pressing the same key in a regular Russian layout gives another code, unique for the
1583+ * letter "Cyrillic I short".
1584+ *
1585+ * @since 1.7
1586+ *
1587+ */
1588+ public int getExtendedKeyCode() {
1589+ return (int)extendedKeyCode;
1590+ }
1591+ /**
1592+ * Returns an extended key code for a unicode character.
1593+ *
1594+ * @return for a unicode character with a corresponding {@code VK_} constant -- this
1595+ * {@code VK_} constant; for a character appearing on the primary
1596+ * level of a known keyboard layout -- a unique integer.
1597+ * If a character does not appear on the primary level of a known keyboard,
1598+ * {@code VK_UNDEFINED} is returned.
1599+ *
1600+ * @since 1.7
1601+ *
1602+ */
1603+ public static int getExtendedKeyCodeForChar(int c) {
1604+ // Return a keycode (if any) associated with a character.
1605+ return sun.awt.ExtendedKeyCodes.getExtendedKeyCodeForChar(c);
1606+ }
1607+
1608+ /**
1609+ * Sets new modifiers by the old ones. The key modifiers
1610+ * override overlaping mouse modifiers.
1611+ */
1612+ private void setNewModifiers() {
1613+ if ((modifiers & SHIFT_MASK) != 0) {
1614+ modifiers |= SHIFT_DOWN_MASK;
1615+ }
1616+ if ((modifiers & ALT_MASK) != 0) {
1617+ modifiers |= ALT_DOWN_MASK;
1618+ }
1619+ if ((modifiers & CTRL_MASK) != 0) {
1620+ modifiers |= CTRL_DOWN_MASK;
1621+ }
1622+ if ((modifiers & META_MASK) != 0) {
1623+ modifiers |= META_DOWN_MASK;
1624+ }
1625+ if ((modifiers & ALT_GRAPH_MASK) != 0) {
1626+ modifiers |= ALT_GRAPH_DOWN_MASK;
1627+ }
1628+ if ((modifiers & BUTTON1_MASK) != 0) {
1629+ modifiers |= BUTTON1_DOWN_MASK;
1630+ }
1631+ }
1632+
1633+ /**
1634+ * Sets old modifiers by the new ones.
1635+ */
1636+ private void setOldModifiers() {
1637+ if ((modifiers & SHIFT_DOWN_MASK) != 0) {
1638+ modifiers |= SHIFT_MASK;
1639+ }
1640+ if ((modifiers & ALT_DOWN_MASK) != 0) {
1641+ modifiers |= ALT_MASK;
1642+ }
1643+ if ((modifiers & CTRL_DOWN_MASK) != 0) {
1644+ modifiers |= CTRL_MASK;
1645+ }
1646+ if ((modifiers & META_DOWN_MASK) != 0) {
1647+ modifiers |= META_MASK;
1648+ }
1649+ if ((modifiers & ALT_GRAPH_DOWN_MASK) != 0) {
1650+ modifiers |= ALT_GRAPH_MASK;
1651+ }
1652+ if ((modifiers & BUTTON1_DOWN_MASK) != 0) {
1653+ modifiers |= BUTTON1_MASK;
1654+ }
1655+ }
1656+
1657+ /**
1658+ * Sets new modifiers by the old ones. The key modifiers
1659+ * override overlaping mouse modifiers.
1660+ * @serial
1661+ */
1662+ private void readObject(ObjectInputStream s)
1663+ throws IOException, ClassNotFoundException {
1664+ s.defaultReadObject();
1665+ if (getModifiers() != 0 && getModifiersEx() == 0) {
1666+ setNewModifiers();
1667+ }
1668+ }
1669+}
java/pkg/java/awt/event/KeyListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/KeyListener.java+73−0
@@ -0,0 +1,73 @@
1+/*
2+ * Copyright (c) 1996, 2006, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving keyboard events (keystrokes).
32+ * The class that is interested in processing a keyboard event
33+ * either implements this interface (and all the methods it
34+ * contains) or extends the abstract <code>KeyAdapter</code> class
35+ * (overriding only the methods of interest).
36+ * <P>
37+ * The listener object created from that class is then registered with a
38+ * component using the component's <code>addKeyListener</code>
39+ * method. A keyboard event is generated when a key is pressed, released,
40+ * or typed. The relevant method in the listener
41+ * object is then invoked, and the <code>KeyEvent</code> is passed to it.
42+ *
43+ * @author Carl Quinn
44+ *
45+ * @see KeyAdapter
46+ * @see KeyEvent
47+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/keylistener.html">Tutorial: Writing a Key Listener</a>
48+ *
49+ * @since 1.1
50+ */
51+public interface KeyListener extends EventListener {
52+
53+ /**
54+ * Invoked when a key has been typed.
55+ * See the class description for {@link KeyEvent} for a definition of
56+ * a key typed event.
57+ */
58+ public void keyTyped(KeyEvent e);
59+
60+ /**
61+ * Invoked when a key has been pressed.
62+ * See the class description for {@link KeyEvent} for a definition of
63+ * a key pressed event.
64+ */
65+ public void keyPressed(KeyEvent e);
66+
67+ /**
68+ * Invoked when a key has been released.
69+ * See the class description for {@link KeyEvent} for a definition of
70+ * a key released event.
71+ */
72+ public void keyReleased(KeyEvent e);
73+}
java/pkg/java/awt/event/MouseAdapter.class+0−0

Binary file not shown.

java/pkg/java/awt/event/MouseAdapter.java+113−0
@@ -0,0 +1,113 @@
1+/*
2+ * Copyright (c) 1996, 2006, 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.event;
27+
28+/**
29+ * An abstract adapter class for receiving mouse events.
30+ * The methods in this class are empty. This class exists as
31+ * convenience for creating listener objects.
32+ * <P>
33+ * Mouse events let you track when a mouse is pressed, released, clicked,
34+ * moved, dragged, when it enters a component, when it exits and
35+ * when a mouse wheel is moved.
36+ * <P>
37+ * Extend this class to create a {@code MouseEvent}
38+ * (including drag and motion events) or/and {@code MouseWheelEvent}
39+ * listener and override the methods for the events of interest. (If you implement the
40+ * {@code MouseListener},
41+ * {@code MouseMotionListener}
42+ * interface, you have to define all of
43+ * the methods in it. This abstract class defines null methods for them
44+ * all, so you can only have to define methods for events you care about.)
45+ * <P>
46+ * Create a listener object using the extended class and then register it with
47+ * a component using the component's {@code addMouseListener}
48+ * {@code addMouseMotionListener}, {@code addMouseWheelListener}
49+ * methods.
50+ * The relevant method in the listener object is invoked and the {@code MouseEvent}
51+ * or {@code MouseWheelEvent} is passed to it in following cases:
52+ * <p><ul>
53+ * <li>when a mouse button is pressed, released, or clicked (pressed and released)
54+ * <li>when the mouse cursor enters or exits the component
55+ * <li>when the mouse wheel rotated, or mouse moved or dragged
56+ * </ul>
57+ *
58+ * @author Carl Quinn
59+ * @author Andrei Dmitriev
60+ *
61+ * @see MouseEvent
62+ * @see MouseWheelEvent
63+ * @see MouseListener
64+ * @see MouseMotionListener
65+ * @see MouseWheelListener
66+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/mouselistener.html">Tutorial: Writing a Mouse Listener</a>
67+ *
68+ * @since 1.1
69+ */
70+public abstract class MouseAdapter implements MouseListener, MouseWheelListener, MouseMotionListener {
71+ /**
72+ * {@inheritDoc}
73+ */
74+ public void mouseClicked(MouseEvent e) {}
75+
76+ /**
77+ * {@inheritDoc}
78+ */
79+ public void mousePressed(MouseEvent e) {}
80+
81+ /**
82+ * {@inheritDoc}
83+ */
84+ public void mouseReleased(MouseEvent e) {}
85+
86+ /**
87+ * {@inheritDoc}
88+ */
89+ public void mouseEntered(MouseEvent e) {}
90+
91+ /**
92+ * {@inheritDoc}
93+ */
94+ public void mouseExited(MouseEvent e) {}
95+
96+ /**
97+ * {@inheritDoc}
98+ * @since 1.6
99+ */
100+ public void mouseWheelMoved(MouseWheelEvent e){}
101+
102+ /**
103+ * {@inheritDoc}
104+ * @since 1.6
105+ */
106+ public void mouseDragged(MouseEvent e){}
107+
108+ /**
109+ * {@inheritDoc}
110+ * @since 1.6
111+ */
112+ public void mouseMoved(MouseEvent e){}
113+}
java/pkg/java/awt/event/MouseEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/MouseEvent.java+1171−0
@@ -0,0 +1,1171 @@
1+/*
2+ * Copyright (c) 1996, 2008, 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.event;
27+
28+import java.awt.Component;
29+import java.awt.GraphicsEnvironment;
30+import java.awt.Point;
31+import java.awt.Toolkit;
32+import java.io.IOException;
33+import java.io.ObjectInputStream;
34+import java.awt.IllegalComponentStateException;
35+import java.awt.MouseInfo;
36+import sun.awt.SunToolkit;
37+
38+/**
39+ * An event which indicates that a mouse action occurred in a component.
40+ * A mouse action is considered to occur in a particular component if and only
41+ * if the mouse cursor is over the unobscured part of the component's bounds
42+ * when the action happens.
43+ * For lightweight components, such as Swing's components, mouse events
44+ * are only dispatched to the component if the mouse event type has been
45+ * enabled on the component. A mouse event type is enabled by adding the
46+ * appropriate mouse-based {@code EventListener} to the component
47+ * ({@link MouseListener} or {@link MouseMotionListener}), or by invoking
48+ * {@link Component#enableEvents(long)} with the appropriate mask parameter
49+ * ({@code AWTEvent.MOUSE_EVENT_MASK} or {@code AWTEvent.MOUSE_MOTION_EVENT_MASK}).
50+ * If the mouse event type has not been enabled on the component, the
51+ * corresponding mouse events are dispatched to the first ancestor that
52+ * has enabled the mouse event type.
53+ *<p>
54+ * For example, if a {@code MouseListener} has been added to a component, or
55+ * {@code enableEvents(AWTEvent.MOUSE_EVENT_MASK)} has been invoked, then all
56+ * the events defined by {@code MouseListener} are dispatched to the component.
57+ * On the other hand, if a {@code MouseMotionListener} has not been added and
58+ * {@code enableEvents} has not been invoked with
59+ * {@code AWTEvent.MOUSE_MOTION_EVENT_MASK}, then mouse motion events are not
60+ * dispatched to the component. Instead the mouse motion events are
61+ * dispatched to the first ancestors that has enabled mouse motion
62+ * events.
63+ * <P>
64+ * This low-level event is generated by a component object for:
65+ * <ul>
66+ * <li>Mouse Events
67+ * <ul>
68+ * <li>a mouse button is pressed
69+ * <li>a mouse button is released
70+ * <li>a mouse button is clicked (pressed and released)
71+ * <li>the mouse cursor enters the unobscured part of component's geometry
72+ * <li>the mouse cursor exits the unobscured part of component's geometry
73+ * </ul>
74+ * <li> Mouse Motion Events
75+ * <ul>
76+ * <li>the mouse is moved
77+ * <li>the mouse is dragged
78+ * </ul>
79+ * </ul>
80+ * <P>
81+ * A <code>MouseEvent</code> object is passed to every
82+ * <code>MouseListener</code>
83+ * or <code>MouseAdapter</code> object which is registered to receive
84+ * the "interesting" mouse events using the component's
85+ * <code>addMouseListener</code> method.
86+ * (<code>MouseAdapter</code> objects implement the
87+ * <code>MouseListener</code> interface.) Each such listener object
88+ * gets a <code>MouseEvent</code> containing the mouse event.
89+ * <P>
90+ * A <code>MouseEvent</code> object is also passed to every
91+ * <code>MouseMotionListener</code> or
92+ * <code>MouseMotionAdapter</code> object which is registered to receive
93+ * mouse motion events using the component's
94+ * <code>addMouseMotionListener</code>
95+ * method. (<code>MouseMotionAdapter</code> objects implement the
96+ * <code>MouseMotionListener</code> interface.) Each such listener object
97+ * gets a <code>MouseEvent</code> containing the mouse motion event.
98+ * <P>
99+ * When a mouse button is clicked, events are generated and sent to the
100+ * registered <code>MouseListener</code>s.
101+ * The state of modal keys can be retrieved using {@link InputEvent#getModifiers}
102+ * and {@link InputEvent#getModifiersEx}.
103+ * The button mask returned by {@link InputEvent#getModifiers} reflects
104+ * only the button that changed state, not the current state of all buttons.
105+ * (Note: Due to overlap in the values of ALT_MASK/BUTTON2_MASK and
106+ * META_MASK/BUTTON3_MASK, this is not always true for mouse events involving
107+ * modifier keys).
108+ * To get the state of all buttons and modifier keys, use
109+ * {@link InputEvent#getModifiersEx}.
110+ * The button which has changed state is returned by {@link MouseEvent#getButton}
111+ * <P>
112+ * For example, if the first mouse button is pressed, events are sent in the
113+ * following order:
114+ * <PRE>
115+ * <b >id </b > <b >modifiers </b > <b >button </b >
116+ * <code>MOUSE_PRESSED</code>: <code>BUTTON1_MASK</code> <code>BUTTON1</code>
117+ * <code>MOUSE_RELEASED</code>: <code>BUTTON1_MASK</code> <code>BUTTON1</code>
118+ * <code>MOUSE_CLICKED</code>: <code>BUTTON1_MASK</code> <code>BUTTON1</code>
119+ * </PRE>
120+ * When multiple mouse buttons are pressed, each press, release, and click
121+ * results in a separate event.
122+ * <P>
123+ * For example, if the user presses <b>button 1</b> followed by
124+ * <b>button 2</b>, and then releases them in the same order,
125+ * the following sequence of events is generated:
126+ * <PRE>
127+ * <b >id </b > <b >modifiers </b > <b >button </b >
128+ * <code>MOUSE_PRESSED</code>: <code>BUTTON1_MASK</code> <code>BUTTON1</code>
129+ * <code>MOUSE_PRESSED</code>: <code>BUTTON2_MASK</code> <code>BUTTON2</code>
130+ * <code>MOUSE_RELEASED</code>: <code>BUTTON1_MASK</code> <code>BUTTON1</code>
131+ * <code>MOUSE_CLICKED</code>: <code>BUTTON1_MASK</code> <code>BUTTON1</code>
132+ * <code>MOUSE_RELEASED</code>: <code>BUTTON2_MASK</code> <code>BUTTON2</code>
133+ * <code>MOUSE_CLICKED</code>: <code>BUTTON2_MASK</code> <code>BUTTON2</code>
134+ * </PRE>
135+ * If <b>button 2</b> is released first, the
136+ * <code>MOUSE_RELEASED</code>/<code>MOUSE_CLICKED</code> pair
137+ * for <code>BUTTON2_MASK</code> arrives first,
138+ * followed by the pair for <code>BUTTON1_MASK</code>.
139+ * <p>
140+ * Some extra mouse buttons are added to extend the standard set of buttons
141+ * represented by the following constants:{@code BUTTON1}, {@code BUTTON2}, and {@code BUTTON3}.
142+ * Extra buttons have no assigned {@code BUTTONx}
143+ * constants as well as their button masks have no assigned {@code BUTTONx_DOWN_MASK}
144+ * constants. Nevertheless, ordinal numbers starting from 4 may be
145+ * used as button numbers (button ids). Values obtained by the
146+ * {@link InputEvent#getMaskForButton(int) getMaskForButton(button)} method may be used
147+ * as button masks.
148+ * <p>
149+ * <code>MOUSE_DRAGGED</code> events are delivered to the <code>Component</code>
150+ * in which the mouse button was pressed until the mouse button is released
151+ * (regardless of whether the mouse position is within the bounds of the
152+ * <code>Component</code>). Due to platform-dependent Drag&Drop implementations,
153+ * <code>MOUSE_DRAGGED</code> events may not be delivered during a native
154+ * Drag&Drop operation.
155+ *
156+ * In a multi-screen environment mouse drag events are delivered to the
157+ * <code>Component</code> even if the mouse position is outside the bounds of the
158+ * <code>GraphicsConfiguration</code> associated with that
159+ * <code>Component</code>. However, the reported position for mouse drag events
160+ * in this case may differ from the actual mouse position:
161+ * <ul>
162+ * <li>In a multi-screen environment without a virtual device:
163+ * <br>
164+ * The reported coordinates for mouse drag events are clipped to fit within the
165+ * bounds of the <code>GraphicsConfiguration</code> associated with
166+ * the <code>Component</code>.
167+ * <li>In a multi-screen environment with a virtual device:
168+ * <br>
169+ * The reported coordinates for mouse drag events are clipped to fit within the
170+ * bounds of the virtual device associated with the <code>Component</code>.
171+ * </ul>
172+ * <p>
173+ * An unspecified behavior will be caused if the {@code id} parameter
174+ * of any particular {@code MouseEvent} instance is not
175+ * in the range from {@code MOUSE_FIRST} to {@code MOUSE_LAST}-1
176+ * ({@code MOUSE_WHEEL} is not acceptable).
177+ *
178+ * @author Carl Quinn
179+ *
180+ * @see MouseAdapter
181+ * @see MouseListener
182+ * @see MouseMotionAdapter
183+ * @see MouseMotionListener
184+ * @see MouseWheelListener
185+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/mouselistener.html">Tutorial: Writing a Mouse Listener</a>
186+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/mousemotionlistener.html">Tutorial: Writing a Mouse Motion Listener</a>
187+ *
188+ * @since 1.1
189+ */
190+public class MouseEvent extends InputEvent {
191+
192+ /**
193+ * The first number in the range of ids used for mouse events.
194+ */
195+ public static final int MOUSE_FIRST = 500;
196+
197+ /**
198+ * The last number in the range of ids used for mouse events.
199+ */
200+ public static final int MOUSE_LAST = 507;
201+
202+ /**
203+ * The "mouse clicked" event. This <code>MouseEvent</code>
204+ * occurs when a mouse button is pressed and released.
205+ */
206+ public static final int MOUSE_CLICKED = MOUSE_FIRST;
207+
208+ /**
209+ * The "mouse pressed" event. This <code>MouseEvent</code>
210+ * occurs when a mouse button is pushed down.
211+ */
212+ public static final int MOUSE_PRESSED = 1 + MOUSE_FIRST; //Event.MOUSE_DOWN
213+
214+ /**
215+ * The "mouse released" event. This <code>MouseEvent</code>
216+ * occurs when a mouse button is let up.
217+ */
218+ public static final int MOUSE_RELEASED = 2 + MOUSE_FIRST; //Event.MOUSE_UP
219+
220+ /**
221+ * The "mouse moved" event. This <code>MouseEvent</code>
222+ * occurs when the mouse position changes.
223+ */
224+ public static final int MOUSE_MOVED = 3 + MOUSE_FIRST; //Event.MOUSE_MOVE
225+
226+ /**
227+ * The "mouse entered" event. This <code>MouseEvent</code>
228+ * occurs when the mouse cursor enters the unobscured part of component's
229+ * geometry.
230+ */
231+ public static final int MOUSE_ENTERED = 4 + MOUSE_FIRST; //Event.MOUSE_ENTER
232+
233+ /**
234+ * The "mouse exited" event. This <code>MouseEvent</code>
235+ * occurs when the mouse cursor exits the unobscured part of component's
236+ * geometry.
237+ */
238+ public static final int MOUSE_EXITED = 5 + MOUSE_FIRST; //Event.MOUSE_EXIT
239+
240+ /**
241+ * The "mouse dragged" event. This <code>MouseEvent</code>
242+ * occurs when the mouse position changes while a mouse button is pressed.
243+ */
244+ public static final int MOUSE_DRAGGED = 6 + MOUSE_FIRST; //Event.MOUSE_DRAG
245+
246+ /**
247+ * The "mouse wheel" event. This is the only <code>MouseWheelEvent</code>.
248+ * It occurs when a mouse equipped with a wheel has its wheel rotated.
249+ * @since 1.4
250+ */
251+ public static final int MOUSE_WHEEL = 7 + MOUSE_FIRST;
252+
253+ /**
254+ * Indicates no mouse buttons; used by {@link #getButton}.
255+ * @since 1.4
256+ */
257+ public static final int NOBUTTON = 0;
258+
259+ /**
260+ * Indicates mouse button #1; used by {@link #getButton}.
261+ * @since 1.4
262+ */
263+ public static final int BUTTON1 = 1;
264+
265+ /**
266+ * Indicates mouse button #2; used by {@link #getButton}.
267+ * @since 1.4
268+ */
269+ public static final int BUTTON2 = 2;
270+
271+ /**
272+ * Indicates mouse button #3; used by {@link #getButton}.
273+ * @since 1.4
274+ */
275+ public static final int BUTTON3 = 3;
276+
277+ /**
278+ * The mouse event's x coordinate.
279+ * The x value is relative to the component that fired the event.
280+ *
281+ * @serial
282+ * @see #getX()
283+ */
284+ int x;
285+
286+ /**
287+ * The mouse event's y coordinate.
288+ * The y value is relative to the component that fired the event.
289+ *
290+ * @serial
291+ * @see #getY()
292+ */
293+ int y;
294+
295+ /**
296+ * The mouse event's x absolute coordinate.
297+ * In a virtual device multi-screen environment in which the
298+ * desktop area could span multiple physical screen devices,
299+ * this coordinate is relative to the virtual coordinate system.
300+ * Otherwise, this coordinate is relative to the coordinate system
301+ * associated with the Component's GraphicsConfiguration.
302+ *
303+ * @serial
304+ */
305+ private int xAbs;
306+
307+ /**
308+ * The mouse event's y absolute coordinate.
309+ * In a virtual device multi-screen environment in which the
310+ * desktop area could span multiple physical screen devices,
311+ * this coordinate is relative to the virtual coordinate system.
312+ * Otherwise, this coordinate is relative to the coordinate system
313+ * associated with the Component's GraphicsConfiguration.
314+ *
315+ * @serial
316+ */
317+ private int yAbs;
318+
319+ /**
320+ * Indicates the number of quick consecutive clicks of
321+ * a mouse button.
322+ * clickCount will be valid for only three mouse events :<BR>
323+ * <code>MOUSE_CLICKED</code>,
324+ * <code>MOUSE_PRESSED</code> and
325+ * <code>MOUSE_RELEASED</code>.
326+ * For the above, the <code>clickCount</code> will be at least 1.
327+ * For all other events the count will be 0.
328+ *
329+ * @serial
330+ * @see #getClickCount().
331+ */
332+ int clickCount;
333+
334+ /**
335+ * Indicates which, if any, of the mouse buttons has changed state.
336+ *
337+ * The valid values are ranged from 0 to the value returned by the
338+ * {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()} method.
339+ * This range already includes constants {@code NOBUTTON}, {@code BUTTON1},
340+ * {@code BUTTON2}, and {@code BUTTON3}
341+ * if these buttons are present. So it is allowed to use these constants too.
342+ * For example, for a mouse with two buttons this field may contain the following values:
343+ * <ul>
344+ * <li> 0 ({@code NOBUTTON})
345+ * <li> 1 ({@code BUTTON1})
346+ * <li> 2 ({@code BUTTON2})
347+ * </ul>
348+ * If a mouse has 5 buttons, this field may contain the following values:
349+ * <ul>
350+ * <li> 0 ({@code NOBUTTON})
351+ * <li> 1 ({@code BUTTON1})
352+ * <li> 2 ({@code BUTTON2})
353+ * <li> 3 ({@code BUTTON3})
354+ * <li> 4
355+ * <li> 5
356+ * </ul>
357+ * If support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled()} disabled by Java
358+ * then the field may not contain the value larger than {@code BUTTON3}.
359+ * @serial
360+ * @see #getButton()
361+ * @see java.awt.Toolkit#areExtraMouseButtonsEnabled()
362+ */
363+ int button;
364+
365+ /**
366+ * A property used to indicate whether a Popup Menu
367+ * should appear with a certain gestures.
368+ * If <code>popupTrigger</code> = <code>false</code>,
369+ * no popup menu should appear. If it is <code>true</code>
370+ * then a popup menu should appear.
371+ *
372+ * @serial
373+ * @see java.awt.PopupMenu
374+ * @see #isPopupTrigger()
375+ */
376+ boolean popupTrigger = false;
377+
378+ /*
379+ * JDK 1.1 serialVersionUID
380+ */
381+ private static final long serialVersionUID = -991214153494842848L;
382+
383+ /**
384+ * A number of buttons available on the mouse at the {@code Toolkit} machinery startup.
385+ */
386+ private static int cachedNumberOfButtons;
387+
388+ static {
389+ /* ensure that the necessary native libraries are loaded */
390+ NativeLibLoader.loadLibraries();
391+ if (!GraphicsEnvironment.isHeadless()) {
392+ initIDs();
393+ }
394+ final Toolkit tk = Toolkit.getDefaultToolkit();
395+ if (tk instanceof SunToolkit) {
396+ cachedNumberOfButtons = ((SunToolkit)tk).getNumberOfButtons();
397+ } else {
398+ //It's expected that some toolkits (Headless,
399+ //whatever besides SunToolkit) could also operate.
400+ cachedNumberOfButtons = 3;
401+ }
402+ }
403+
404+ /**
405+ * Initialize JNI field and method IDs for fields that may be
406+ accessed from C.
407+ */
408+ private static native void initIDs();
409+
410+ /**
411+ * Returns the absolute x, y position of the event.
412+ * In a virtual device multi-screen environment in which the
413+ * desktop area could span multiple physical screen devices,
414+ * these coordinates are relative to the virtual coordinate system.
415+ * Otherwise, these coordinates are relative to the coordinate system
416+ * associated with the Component's GraphicsConfiguration.
417+ *
418+ * @return a <code>Point</code> object containing the absolute x
419+ * and y coordinates.
420+ *
421+ * @see java.awt.GraphicsConfiguration
422+ * @since 1.6
423+ */
424+ public Point getLocationOnScreen(){
425+ return new Point(xAbs, yAbs);
426+ }
427+
428+ /**
429+ * Returns the absolute horizontal x position of the event.
430+ * In a virtual device multi-screen environment in which the
431+ * desktop area could span multiple physical screen devices,
432+ * this coordinate is relative to the virtual coordinate system.
433+ * Otherwise, this coordinate is relative to the coordinate system
434+ * associated with the Component's GraphicsConfiguration.
435+ *
436+ * @return x an integer indicating absolute horizontal position.
437+ *
438+ * @see java.awt.GraphicsConfiguration
439+ * @since 1.6
440+ */
441+ public int getXOnScreen() {
442+ return xAbs;
443+ }
444+
445+ /**
446+ * Returns the absolute vertical y position of the event.
447+ * In a virtual device multi-screen environment in which the
448+ * desktop area could span multiple physical screen devices,
449+ * this coordinate is relative to the virtual coordinate system.
450+ * Otherwise, this coordinate is relative to the coordinate system
451+ * associated with the Component's GraphicsConfiguration.
452+ *
453+ * @return y an integer indicating absolute vertical position.
454+ *
455+ * @see java.awt.GraphicsConfiguration
456+ * @since 1.6
457+ */
458+ public int getYOnScreen() {
459+ return yAbs;
460+ }
461+
462+ /**
463+ * Constructs a <code>MouseEvent</code> object with the
464+ * specified source component,
465+ * type, time, modifiers, coordinates, click count, popupTrigger flag,
466+ * and button number.
467+ * <p>
468+ * Creating an invalid event (such
469+ * as by using more than one of the old _MASKs, or modifier/button
470+ * values which don't match) results in unspecified behavior.
471+ * An invocation of the form
472+ * <tt>MouseEvent(source, id, when, modifiers, x, y, clickCount, popupTrigger, button)</tt>
473+ * behaves in exactly the same way as the invocation
474+ * <tt> {@link #MouseEvent(Component, int, long, int, int, int,
475+ * int, int, int, boolean, int) MouseEvent}(source, id, when, modifiers,
476+ * x, y, xAbs, yAbs, clickCount, popupTrigger, button)</tt>
477+ * where xAbs and yAbs defines as source's location on screen plus
478+ * relative coordinates x and y.
479+ * xAbs and yAbs are set to zero if the source is not showing.
480+ * This method throws an
481+ * <code>IllegalArgumentException</code> if <code>source</code>
482+ * is <code>null</code>.
483+ *
484+ * @param source The <code>Component</code> that originated the event
485+ * @param id An integer indicating the type of event.
486+ * For information on allowable values, see
487+ * the class description for {@link MouseEvent}
488+ * @param when A long integer that gives the time the event occurred.
489+ * Passing negative or zero value
490+ * is not recommended
491+ * @param modifiers The modifier keys down during event (e.g. shift, ctrl,
492+ * alt, meta)
493+ * Passing negative parameter
494+ * is not recommended.
495+ * Zero value means that no modifiers were passed.
496+ * Use either an extended _DOWN_MASK or old _MASK modifiers,
497+ * however do not mix models in the one event.
498+ * The extended modifiers are preferred for using
499+ * @param x The horizontal x coordinate for the mouse location.
500+ * It is allowed to pass negative values
501+ * @param y The vertical y coordinate for the mouse location.
502+ * It is allowed to pass negative values
503+ * @param clickCount The number of mouse clicks associated with event.
504+ * Passing negative value
505+ * is not recommended
506+ * @param popupTrigger A boolean that equals {@code true} if this event
507+ * is a trigger for a popup menu
508+ * @param button An integer that indicates, which of the mouse buttons has
509+ * changed its state.
510+ * The following rules are applied to this parameter:
511+ * <ul>
512+ * <li>If support for the extended mouse buttons is
513+ * {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
514+ * then it is allowed to create {@code MouseEvent} objects only with the standard buttons:
515+ * {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2}, and
516+ * {@code BUTTON3}.
517+ * <li> If support for the extended mouse buttons is
518+ * {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
519+ * then it is allowed to create {@code MouseEvent} objects with
520+ * the standard buttons.
521+ * In case the support for extended mouse buttons is
522+ * {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java, then
523+ * in addition to the standard buttons, {@code MouseEvent} objects can be created
524+ * using buttons from the range starting from 4 to
525+ * {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
526+ * if the mouse has more than three buttons.
527+ * </ul>
528+ * @throws IllegalArgumentException if {@code button} is less then zero
529+ * @throws IllegalArgumentException if <code>source</code> is null
530+ * @throws IllegalArgumentException if {@code button} is greater then BUTTON3 and the support for extended mouse buttons is
531+ * {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
532+ * @throws IllegalArgumentException if {@code button} is greater then the
533+ * {@link java.awt.MouseInfo#getNumberOfButtons() current number of buttons} and the support
534+ * for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled}
535+ * by Java
536+ * @throws IllegalArgumentException if an invalid <code>button</code>
537+ * value is passed in
538+ * @throws IllegalArgumentException if <code>source</code> is null
539+ * @see #getSource()
540+ * @see #getID()
541+ * @see #getWhen()
542+ * @see #getModifiers()
543+ * @see #getX()
544+ * @see #getY()
545+ * @see #getClickCount()
546+ * @see #isPopupTrigger()
547+ * @see #getButton()
548+ * @since 1.4
549+ */
550+ public MouseEvent(Component source, int id, long when, int modifiers,
551+ int x, int y, int clickCount, boolean popupTrigger,
552+ int button)
553+ {
554+ this(source, id, when, modifiers, x, y, 0, 0, clickCount, popupTrigger, button);
555+ Point eventLocationOnScreen = new Point(0, 0);
556+ try {
557+ eventLocationOnScreen = source.getLocationOnScreen();
558+ this.xAbs = eventLocationOnScreen.x + x;
559+ this.yAbs = eventLocationOnScreen.y + y;
560+ } catch (IllegalComponentStateException e){
561+ this.xAbs = 0;
562+ this.yAbs = 0;
563+ }
564+ }
565+
566+ /**
567+ * Constructs a <code>MouseEvent</code> object with the
568+ * specified source component,
569+ * type, modifiers, coordinates, click count, and popupTrigger flag.
570+ * An invocation of the form
571+ * <tt>MouseEvent(source, id, when, modifiers, x, y, clickCount, popupTrigger)</tt>
572+ * behaves in exactly the same way as the invocation
573+ * <tt> {@link #MouseEvent(Component, int, long, int, int, int,
574+ * int, int, int, boolean, int) MouseEvent}(source, id, when, modifiers,
575+ * x, y, xAbs, yAbs, clickCount, popupTrigger, MouseEvent.NOBUTTON)</tt>
576+ * where xAbs and yAbs defines as source's location on screen plus
577+ * relative coordinates x and y.
578+ * xAbs and yAbs are set to zero if the source is not showing.
579+ * This method throws an <code>IllegalArgumentException</code>
580+ * if <code>source</code> is <code>null</code>.
581+ *
582+ * @param source The <code>Component</code> that originated the event
583+ * @param id An integer indicating the type of event.
584+ * For information on allowable values, see
585+ * the class description for {@link MouseEvent}
586+ * @param when A long integer that gives the time the event occurred.
587+ * Passing negative or zero value
588+ * is not recommended
589+ * @param modifiers The modifier keys down during event (e.g. shift, ctrl,
590+ * alt, meta)
591+ * Passing negative parameter
592+ * is not recommended.
593+ * Zero value means that no modifiers were passed.
594+ * Use either an extended _DOWN_MASK or old _MASK modifiers,
595+ * however do not mix models in the one event.
596+ * The extended modifiers are preferred for using
597+ * @param x The horizontal x coordinate for the mouse location.
598+ * It is allowed to pass negative values
599+ * @param y The vertical y coordinate for the mouse location.
600+ * It is allowed to pass negative values
601+ * @param clickCount The number of mouse clicks associated with event.
602+ * Passing negative value
603+ * is not recommended
604+ * @param popupTrigger A boolean that equals {@code true} if this event
605+ * is a trigger for a popup menu
606+ * @throws IllegalArgumentException if <code>source</code> is null
607+ * @see #getSource()
608+ * @see #getID()
609+ * @see #getWhen()
610+ * @see #getModifiers()
611+ * @see #getX()
612+ * @see #getY()
613+ * @see #getClickCount()
614+ * @see #isPopupTrigger()
615+ */
616+ public MouseEvent(Component source, int id, long when, int modifiers,
617+ int x, int y, int clickCount, boolean popupTrigger) {
618+ this(source, id, when, modifiers, x, y, clickCount, popupTrigger, NOBUTTON);
619+ }
620+
621+
622+ /* if the button is an extra button and it is released or clicked then in Xsystem its state
623+ is not modified. Exclude this button number from ExtModifiers mask.*/
624+ transient private boolean shouldExcludeButtonFromExtModifiers = false;
625+
626+ /**
627+ * {@inheritDoc}
628+ */
629+ public int getModifiersEx() {
630+ int tmpModifiers = modifiers;
631+ if (shouldExcludeButtonFromExtModifiers) {
632+ tmpModifiers &= ~(InputEvent.getMaskForButton(getButton()));
633+ }
634+ return tmpModifiers & ~JDK_1_3_MODIFIERS;
635+ }
636+
637+ /**
638+ * Constructs a <code>MouseEvent</code> object with the
639+ * specified source component,
640+ * type, time, modifiers, coordinates, absolute coordinates, click count, popupTrigger flag,
641+ * and button number.
642+ * <p>
643+ * Creating an invalid event (such
644+ * as by using more than one of the old _MASKs, or modifier/button
645+ * values which don't match) results in unspecified behavior.
646+ * Even if inconsistent values for relative and absolute coordinates are
647+ * passed to the constructor, the mouse event instance is still
648+ * created and no exception is thrown.
649+ * This method throws an
650+ * <code>IllegalArgumentException</code> if <code>source</code>
651+ * is <code>null</code>.
652+ *
653+ * @param source The <code>Component</code> that originated the event
654+ * @param id An integer indicating the type of event.
655+ * For information on allowable values, see
656+ * the class description for {@link MouseEvent}
657+ * @param when A long integer that gives the time the event occurred.
658+ * Passing negative or zero value
659+ * is not recommended
660+ * @param modifiers The modifier keys down during event (e.g. shift, ctrl,
661+ * alt, meta)
662+ * Passing negative parameter
663+ * is not recommended.
664+ * Zero value means that no modifiers were passed.
665+ * Use either an extended _DOWN_MASK or old _MASK modifiers,
666+ * however do not mix models in the one event.
667+ * The extended modifiers are preferred for using
668+ * @param x The horizontal x coordinate for the mouse location.
669+ * It is allowed to pass negative values
670+ * @param y The vertical y coordinate for the mouse location.
671+ * It is allowed to pass negative values
672+ * @param xAbs The absolute horizontal x coordinate for the mouse location
673+ * It is allowed to pass negative values
674+ * @param yAbs The absolute vertical y coordinate for the mouse location
675+ * It is allowed to pass negative values
676+ * @param clickCount The number of mouse clicks associated with event.
677+ * Passing negative value
678+ * is not recommended
679+ * @param popupTrigger A boolean that equals {@code true} if this event
680+ * is a trigger for a popup menu
681+ * @param button An integer that indicates, which of the mouse buttons has
682+ * changed its state.
683+ * The following rules are applied to this parameter:
684+ * <ul>
685+ * <li>If support for the extended mouse buttons is
686+ * {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
687+ * then it is allowed to create {@code MouseEvent} objects only with the standard buttons:
688+ * {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2}, and
689+ * {@code BUTTON3}.
690+ * <li> If support for the extended mouse buttons is
691+ * {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
692+ * then it is allowed to create {@code MouseEvent} objects with
693+ * the standard buttons.
694+ * In case the support for extended mouse buttons is
695+ * {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java, then
696+ * in addition to the standard buttons, {@code MouseEvent} objects can be created
697+ * using buttons from the range starting from 4 to
698+ * {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
699+ * if the mouse has more than three buttons.
700+ * </ul>
701+ * @throws IllegalArgumentException if {@code button} is less then zero
702+ * @throws IllegalArgumentException if <code>source</code> is null
703+ * @throws IllegalArgumentException if {@code button} is greater then BUTTON3 and the support for extended mouse buttons is
704+ * {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
705+ * @throws IllegalArgumentException if {@code button} is greater then the
706+ * {@link java.awt.MouseInfo#getNumberOfButtons() current number of buttons} and the support
707+ * for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled}
708+ * by Java
709+ * @throws IllegalArgumentException if an invalid <code>button</code>
710+ * value is passed in
711+ * @throws IllegalArgumentException if <code>source</code> is null
712+ * @see #getSource()
713+ * @see #getID()
714+ * @see #getWhen()
715+ * @see #getModifiers()
716+ * @see #getX()
717+ * @see #getY()
718+ * @see #getXOnScreen()
719+ * @see #getYOnScreen()
720+ * @see #getClickCount()
721+ * @see #isPopupTrigger()
722+ * @see #getButton()
723+ * @see #button
724+ * @see Toolkit#areExtraMouseButtonsEnabled()
725+ * @see java.awt.MouseInfo#getNumberOfButtons()
726+ * @see InputEvent#getMaskForButton(int)
727+ * @since 1.6
728+ */
729+ public MouseEvent(Component source, int id, long when, int modifiers,
730+ int x, int y, int xAbs, int yAbs,
731+ int clickCount, boolean popupTrigger, int button)
732+ {
733+ super(source, id, when, modifiers);
734+ this.x = x;
735+ this.y = y;
736+ this.xAbs = xAbs;
737+ this.yAbs = yAbs;
738+ this.clickCount = clickCount;
739+ this.popupTrigger = popupTrigger;
740+ if (button < NOBUTTON){
741+ throw new IllegalArgumentException("Invalid button value :" + button);
742+ }
743+ if (button > BUTTON3) {
744+ if (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
745+ throw new IllegalArgumentException("Extra mouse events are disabled " + button);
746+ } else {
747+ if (button > cachedNumberOfButtons) {
748+ throw new IllegalArgumentException("Nonexistent button " + button);
749+ }
750+ }
751+ // XToolkit: extra buttons are not reporting about their state correctly.
752+ // Being pressed they report the state=0 both on the press and on the release.
753+ // For 1-3 buttons the state value equals zero on press and non-zero on release.
754+ // Other modifiers like Shift, ALT etc seem report well with extra buttons.
755+ // The problem reveals as follows: one button is pressed and then another button is pressed and released.
756+ // So, the getModifiersEx() would not be zero due to a first button and we will skip this modifier.
757+ // This may have to be moved into the peer code instead if possible.
758+
759+ if (getModifiersEx() != 0) { //There is at least one more button in a pressed state.
760+ if (id == MouseEvent.MOUSE_RELEASED || id == MouseEvent.MOUSE_CLICKED){
761+ System.out.println("MEvent. CASE!");
762+ shouldExcludeButtonFromExtModifiers = true;
763+ }
764+ }
765+ }
766+
767+ this.button = button;
768+
769+ if ((getModifiers() != 0) && (getModifiersEx() == 0)) {
770+ setNewModifiers();
771+ } else if ((getModifiers() == 0) &&
772+ (getModifiersEx() != 0 || button != NOBUTTON) &&
773+ (button <= BUTTON3))
774+ {
775+ setOldModifiers();
776+ }
777+ }
778+
779+ /**
780+ * Returns the horizontal x position of the event relative to the
781+ * source component.
782+ *
783+ * @return x an integer indicating horizontal position relative to
784+ * the component
785+ */
786+ public int getX() {
787+ return x;
788+ }
789+
790+ /**
791+ * Returns the vertical y position of the event relative to the
792+ * source component.
793+ *
794+ * @return y an integer indicating vertical position relative to
795+ * the component
796+ */
797+ public int getY() {
798+ return y;
799+ }
800+
801+ /**
802+ * Returns the x,y position of the event relative to the source component.
803+ *
804+ * @return a <code>Point</code> object containing the x and y coordinates
805+ * relative to the source component
806+ *
807+ */
808+ public Point getPoint() {
809+ int x;
810+ int y;
811+ synchronized (this) {
812+ x = this.x;
813+ y = this.y;
814+ }
815+ return new Point(x, y);
816+ }
817+
818+ /**
819+ * Translates the event's coordinates to a new position
820+ * by adding specified <code>x</code> (horizontal) and <code>y</code>
821+ * (vertical) offsets.
822+ *
823+ * @param x the horizontal x value to add to the current x
824+ * coordinate position
825+ * @param y the vertical y value to add to the current y
826+ coordinate position
827+ */
828+ public synchronized void translatePoint(int x, int y) {
829+ this.x += x;
830+ this.y += y;
831+ }
832+
833+ /**
834+ * Returns the number of mouse clicks associated with this event.
835+ *
836+ * @return integer value for the number of clicks
837+ */
838+ public int getClickCount() {
839+ return clickCount;
840+ }
841+
842+ /**
843+ * Returns which, if any, of the mouse buttons has changed state.
844+ * The returned value is ranged
845+ * from 0 to the {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
846+ * value.
847+ * The returned value includes at least the following constants:
848+ * <ul>
849+ * <li> {@code NOBUTTON}
850+ * <li> {@code BUTTON1}
851+ * <li> {@code BUTTON2}
852+ * <li> {@code BUTTON3}
853+ * </ul>
854+ * It is allowed to use those constants to compare with the returned button number in the application.
855+ * For example,
856+ * <pre>
857+ * if (anEvent.getButton() == MouseEvent.BUTTON1) {
858+ * </pre>
859+ * In particular, for a mouse with one, two, or three buttons this method may return the following values:
860+ * <ul>
861+ * <li> 0 ({@code NOBUTTON})
862+ * <li> 1 ({@code BUTTON1})
863+ * <li> 2 ({@code BUTTON2})
864+ * <li> 3 ({@code BUTTON3})
865+ * </ul>
866+ * Button numbers greater then {@code BUTTON3} have no constant identifier. So if a mouse with five buttons is
867+ * installed, this method may return the following values:
868+ * <ul>
869+ * <li> 0 ({@code NOBUTTON})
870+ * <li> 1 ({@code BUTTON1})
871+ * <li> 2 ({@code BUTTON2})
872+ * <li> 3 ({@code BUTTON3})
873+ * <li> 4
874+ * <li> 5
875+ * </ul>
876+ * <p>
877+ * Note: If support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
878+ * then the AWT event subsystem does not produce mouse events for the extended mouse
879+ * buttons. So it is not expected that this method returns anything except {@code NOBUTTON}, {@code BUTTON1},
880+ * {@code BUTTON2}, {@code BUTTON3}.
881+ *
882+ * @return one of the values from 0 to {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
883+ * if support for the extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java.
884+ * That range includes {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2}, {@code BUTTON3};
885+ * <br>
886+ * {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2} or {@code BUTTON3}
887+ * if support for the extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
888+ * @since 1.4
889+ * @see Toolkit#areExtraMouseButtonsEnabled()
890+ * @see java.awt.MouseInfo#getNumberOfButtons()
891+ * @see #MouseEvent(Component, int, long, int, int, int, int, int, int, boolean, int)
892+ * @see InputEvent#getMaskForButton(int)
893+ */
894+ public int getButton() {
895+ return button;
896+ }
897+
898+ /**
899+ * Returns whether or not this mouse event is the popup menu
900+ * trigger event for the platform.
901+ * <p><b>Note</b>: Popup menus are triggered differently
902+ * on different systems. Therefore, <code>isPopupTrigger</code>
903+ * should be checked in both <code>mousePressed</code>
904+ * and <code>mouseReleased</code>
905+ * for proper cross-platform functionality.
906+ *
907+ * @return boolean, true if this event is the popup menu trigger
908+ * for this platform
909+ */
910+ public boolean isPopupTrigger() {
911+ return popupTrigger;
912+ }
913+
914+ /**
915+ * Returns a <code>String</code> instance describing the modifier keys and
916+ * mouse buttons that were down during the event, such as "Shift",
917+ * or "Ctrl+Shift". These strings can be localized by changing
918+ * the <code>awt.properties</code> file.
919+ * <p>
920+ * Note that the <code>InputEvent.ALT_MASK</code> and
921+ * <code>InputEvent.BUTTON2_MASK</code> have equal values,
922+ * so the "Alt" string is returned for both modifiers. Likewise,
923+ * the <code>InputEvent.META_MASK</code> and
924+ * <code>InputEvent.BUTTON3_MASK</code> have equal values,
925+ * so the "Meta" string is returned for both modifiers.
926+ * <p>
927+ * Note that passing negative parameter is incorrect,
928+ * and will cause the returning an unspecified string.
929+ * Zero parameter means that no modifiers were passed and will
930+ * cause the returning an empty string.
931+ * <p>
932+ * @param modifiers A modifier mask describing the modifier keys and
933+ * mouse buttons that were down during the event
934+ * @return string string text description of the combination of modifier
935+ * keys and mouse buttons that were down during the event
936+ * @see InputEvent#getModifiersExText(int)
937+ * @since 1.4
938+ */
939+ public static String getMouseModifiersText(int modifiers) {
940+ StringBuilder buf = new StringBuilder();
941+ if ((modifiers & InputEvent.ALT_MASK) != 0) {
942+ buf.append(Toolkit.getProperty("AWT.alt", "Alt"));
943+ buf.append("+");
944+ }
945+ if ((modifiers & InputEvent.META_MASK) != 0) {
946+ buf.append(Toolkit.getProperty("AWT.meta", "Meta"));
947+ buf.append("+");
948+ }
949+ if ((modifiers & InputEvent.CTRL_MASK) != 0) {
950+ buf.append(Toolkit.getProperty("AWT.control", "Ctrl"));
951+ buf.append("+");
952+ }
953+ if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
954+ buf.append(Toolkit.getProperty("AWT.shift", "Shift"));
955+ buf.append("+");
956+ }
957+ if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
958+ buf.append(Toolkit.getProperty("AWT.altGraph", "Alt Graph"));
959+ buf.append("+");
960+ }
961+ if ((modifiers & InputEvent.BUTTON1_MASK) != 0) {
962+ buf.append(Toolkit.getProperty("AWT.button1", "Button1"));
963+ buf.append("+");
964+ }
965+ if ((modifiers & InputEvent.BUTTON2_MASK) != 0) {
966+ buf.append(Toolkit.getProperty("AWT.button2", "Button2"));
967+ buf.append("+");
968+ }
969+ if ((modifiers & InputEvent.BUTTON3_MASK) != 0) {
970+ buf.append(Toolkit.getProperty("AWT.button3", "Button3"));
971+ buf.append("+");
972+ }
973+
974+ int mask;
975+
976+ // TODO: add a toolkit field that holds a number of button on the mouse.
977+ // As the method getMouseModifiersText() is static and obtain
978+ // an integer as a parameter then we may not restrict this with the number
979+ // of buttons installed on the mouse.
980+ // It's a temporary solution. We need to somehow hold the number of buttons somewhere else.
981+ for (int i = 1; i <= cachedNumberOfButtons; i++){
982+ mask = InputEvent.getMaskForButton(i);
983+ if ((modifiers & mask) != 0 &&
984+ buf.indexOf(Toolkit.getProperty("AWT.button"+i, "Button"+i)) == -1) //1,2,3 buttons may already be there; so don't duplicate it.
985+ {
986+ buf.append(Toolkit.getProperty("AWT.button"+i, "Button"+i));
987+ buf.append("+");
988+ }
989+ }
990+
991+ if (buf.length() > 0) {
992+ buf.setLength(buf.length()-1); // remove trailing '+'
993+ }
994+ return buf.toString();
995+ }
996+
997+ /**
998+ * Returns a parameter string identifying this event.
999+ * This method is useful for event-logging and for debugging.
1000+ *
1001+ * @return a string identifying the event and its attributes
1002+ */
1003+ public String paramString() {
1004+ StringBuilder str = new StringBuilder(80);
1005+
1006+ switch(id) {
1007+ case MOUSE_PRESSED:
1008+ str.append("MOUSE_PRESSED");
1009+ break;
1010+ case MOUSE_RELEASED:
1011+ str.append("MOUSE_RELEASED");
1012+ break;
1013+ case MOUSE_CLICKED:
1014+ str.append("MOUSE_CLICKED");
1015+ break;
1016+ case MOUSE_ENTERED:
1017+ str.append("MOUSE_ENTERED");
1018+ break;
1019+ case MOUSE_EXITED:
1020+ str.append("MOUSE_EXITED");
1021+ break;
1022+ case MOUSE_MOVED:
1023+ str.append("MOUSE_MOVED");
1024+ break;
1025+ case MOUSE_DRAGGED:
1026+ str.append("MOUSE_DRAGGED");
1027+ break;
1028+ case MOUSE_WHEEL:
1029+ str.append("MOUSE_WHEEL");
1030+ break;
1031+ default:
1032+ str.append("unknown type");
1033+ }
1034+
1035+ // (x,y) coordinates
1036+ str.append(",(").append(x).append(",").append(y).append(")");
1037+ str.append(",absolute(").append(xAbs).append(",").append(yAbs).append(")");
1038+
1039+ if (id != MOUSE_DRAGGED && id != MOUSE_MOVED){
1040+ str.append(",button=").append(getButton());
1041+ }
1042+
1043+ if (getModifiers() != 0) {
1044+ str.append(",modifiers=").append(getMouseModifiersText(modifiers));
1045+ }
1046+
1047+ if (getModifiersEx() != 0) {
1048+ //Using plain "modifiers" here does show an excluded extended buttons in the string event representation.
1049+ //getModifiersEx() solves the problem.
1050+ str.append(",extModifiers=").append(getModifiersExText(getModifiersEx()));
1051+ }
1052+
1053+ str.append(",clickCount=").append(clickCount);
1054+
1055+ return str.toString();
1056+ }
1057+
1058+ /**
1059+ * Sets new modifiers by the old ones.
1060+ * Also sets button.
1061+ */
1062+ private void setNewModifiers() {
1063+ if ((modifiers & BUTTON1_MASK) != 0) {
1064+ modifiers |= BUTTON1_DOWN_MASK;
1065+ }
1066+ if ((modifiers & BUTTON2_MASK) != 0) {
1067+ modifiers |= BUTTON2_DOWN_MASK;
1068+ }
1069+ if ((modifiers & BUTTON3_MASK) != 0) {
1070+ modifiers |= BUTTON3_DOWN_MASK;
1071+ }
1072+ if (id == MOUSE_PRESSED
1073+ || id == MOUSE_RELEASED
1074+ || id == MOUSE_CLICKED)
1075+ {
1076+ if ((modifiers & BUTTON1_MASK) != 0) {
1077+ button = BUTTON1;
1078+ modifiers &= ~BUTTON2_MASK & ~BUTTON3_MASK;
1079+ if (id != MOUSE_PRESSED) {
1080+ modifiers &= ~BUTTON1_DOWN_MASK;
1081+ }
1082+ } else if ((modifiers & BUTTON2_MASK) != 0) {
1083+ button = BUTTON2;
1084+ modifiers &= ~BUTTON1_MASK & ~BUTTON3_MASK;
1085+ if (id != MOUSE_PRESSED) {
1086+ modifiers &= ~BUTTON2_DOWN_MASK;
1087+ }
1088+ } else if ((modifiers & BUTTON3_MASK) != 0) {
1089+ button = BUTTON3;
1090+ modifiers &= ~BUTTON1_MASK & ~BUTTON2_MASK;
1091+ if (id != MOUSE_PRESSED) {
1092+ modifiers &= ~BUTTON3_DOWN_MASK;
1093+ }
1094+ }
1095+ }
1096+ if ((modifiers & InputEvent.ALT_MASK) != 0) {
1097+ modifiers |= InputEvent.ALT_DOWN_MASK;
1098+ }
1099+ if ((modifiers & InputEvent.META_MASK) != 0) {
1100+ modifiers |= InputEvent.META_DOWN_MASK;
1101+ }
1102+ if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
1103+ modifiers |= InputEvent.SHIFT_DOWN_MASK;
1104+ }
1105+ if ((modifiers & InputEvent.CTRL_MASK) != 0) {
1106+ modifiers |= InputEvent.CTRL_DOWN_MASK;
1107+ }
1108+ if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
1109+ modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
1110+ }
1111+ }
1112+
1113+ /**
1114+ * Sets old modifiers by the new ones.
1115+ */
1116+ private void setOldModifiers() {
1117+ if (id == MOUSE_PRESSED
1118+ || id == MOUSE_RELEASED
1119+ || id == MOUSE_CLICKED)
1120+ {
1121+ switch(button) {
1122+ case BUTTON1:
1123+ modifiers |= BUTTON1_MASK;
1124+ break;
1125+ case BUTTON2:
1126+ modifiers |= BUTTON2_MASK;
1127+ break;
1128+ case BUTTON3:
1129+ modifiers |= BUTTON3_MASK;
1130+ break;
1131+ }
1132+ } else {
1133+ if ((modifiers & BUTTON1_DOWN_MASK) != 0) {
1134+ modifiers |= BUTTON1_MASK;
1135+ }
1136+ if ((modifiers & BUTTON2_DOWN_MASK) != 0) {
1137+ modifiers |= BUTTON2_MASK;
1138+ }
1139+ if ((modifiers & BUTTON3_DOWN_MASK) != 0) {
1140+ modifiers |= BUTTON3_MASK;
1141+ }
1142+ }
1143+ if ((modifiers & ALT_DOWN_MASK) != 0) {
1144+ modifiers |= ALT_MASK;
1145+ }
1146+ if ((modifiers & META_DOWN_MASK) != 0) {
1147+ modifiers |= META_MASK;
1148+ }
1149+ if ((modifiers & SHIFT_DOWN_MASK) != 0) {
1150+ modifiers |= SHIFT_MASK;
1151+ }
1152+ if ((modifiers & CTRL_DOWN_MASK) != 0) {
1153+ modifiers |= CTRL_MASK;
1154+ }
1155+ if ((modifiers & ALT_GRAPH_DOWN_MASK) != 0) {
1156+ modifiers |= ALT_GRAPH_MASK;
1157+ }
1158+ }
1159+
1160+ /**
1161+ * Sets new modifiers by the old ones.
1162+ * @serial
1163+ */
1164+ private void readObject(ObjectInputStream s)
1165+ throws IOException, ClassNotFoundException {
1166+ s.defaultReadObject();
1167+ if (getModifiers() != 0 && getModifiersEx() == 0) {
1168+ setNewModifiers();
1169+ }
1170+ }
1171+}
java/pkg/java/awt/event/MouseListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/MouseListener.java+84−0
@@ -0,0 +1,84 @@
1+/*
2+ * Copyright (c) 1996, 2006, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving "interesting" mouse events
32+ * (press, release, click, enter, and exit) on a component.
33+ * (To track mouse moves and mouse drags, use the
34+ * <code>MouseMotionListener</code>.)
35+ * <P>
36+ * The class that is interested in processing a mouse event
37+ * either implements this interface (and all the methods it
38+ * contains) or extends the abstract <code>MouseAdapter</code> class
39+ * (overriding only the methods of interest).
40+ * <P>
41+ * The listener object created from that class is then registered with a
42+ * component using the component's <code>addMouseListener</code>
43+ * method. A mouse event is generated when the mouse is pressed, released
44+ * clicked (pressed and released). A mouse event is also generated when
45+ * the mouse cursor enters or leaves a component. When a mouse event
46+ * occurs, the relevant method in the listener object is invoked, and
47+ * the <code>MouseEvent</code> is passed to it.
48+ *
49+ * @author Carl Quinn
50+ *
51+ * @see MouseAdapter
52+ * @see MouseEvent
53+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/mouselistener.html">Tutorial: Writing a Mouse Listener</a>
54+ *
55+ * @since 1.1
56+ */
57+public interface MouseListener extends EventListener {
58+
59+ /**
60+ * Invoked when the mouse button has been clicked (pressed
61+ * and released) on a component.
62+ */
63+ public void mouseClicked(MouseEvent e);
64+
65+ /**
66+ * Invoked when a mouse button has been pressed on a component.
67+ */
68+ public void mousePressed(MouseEvent e);
69+
70+ /**
71+ * Invoked when a mouse button has been released on a component.
72+ */
73+ public void mouseReleased(MouseEvent e);
74+
75+ /**
76+ * Invoked when the mouse enters a component.
77+ */
78+ public void mouseEntered(MouseEvent e);
79+
80+ /**
81+ * Invoked when the mouse exits a component.
82+ */
83+ public void mouseExited(MouseEvent e);
84+}
java/pkg/java/awt/event/MouseMotionAdapter.class+0−0

Binary file not shown.

java/pkg/java/awt/event/MouseMotionAdapter.java+71−0
@@ -0,0 +1,71 @@
1+/*
2+ * Copyright (c) 1996, 2006, 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.event;
27+
28+/**
29+ * An abstract adapter class for receiving mouse motion events.
30+ * The methods in this class are empty. This class exists as
31+ * convenience for creating listener objects.
32+ * <P>
33+ * Mouse motion events occur when a mouse is moved or dragged.
34+ * (Many such events will be generated in a normal program.
35+ * To track clicks and other mouse events, use the MouseAdapter.)
36+ * <P>
37+ * Extend this class to create a <code>MouseEvent</code> listener
38+ * and override the methods for the events of interest. (If you implement the
39+ * <code>MouseMotionListener</code> interface, you have to define all of
40+ * the methods in it. This abstract class defines null methods for them
41+ * all, so you can only have to define methods for events you care about.)
42+ * <P>
43+ * Create a listener object using the extended class and then register it with
44+ * a component using the component's <code>addMouseMotionListener</code>
45+ * method. When the mouse is moved or dragged, the relevant method in the
46+ * listener object is invoked and the <code>MouseEvent</code> is passed to it.
47+ *
48+ * @author Amy Fowler
49+ *
50+ * @see MouseEvent
51+ * @see MouseMotionListener
52+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/mousemotionlistener.html">Tutorial: Writing a Mouse Motion Listener</a>
53+ *
54+ * @since 1.1
55+ */
56+public abstract class MouseMotionAdapter implements MouseMotionListener {
57+ /**
58+ * Invoked when a mouse button is pressed on a component and then
59+ * dragged. Mouse drag events will continue to be delivered to
60+ * the component where the first originated until the mouse button is
61+ * released (regardless of whether the mouse position is within the
62+ * bounds of the component).
63+ */
64+ public void mouseDragged(MouseEvent e) {}
65+
66+ /**
67+ * Invoked when the mouse button has been moved on a component
68+ * (with no buttons no down).
69+ */
70+ public void mouseMoved(MouseEvent e) {}
71+}
java/pkg/java/awt/event/MouseMotionListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/MouseMotionListener.java+75−0
@@ -0,0 +1,75 @@
1+/*
2+ * Copyright (c) 1996, 2006, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving mouse motion events on a component.
32+ * (For clicks and other mouse events, use the <code>MouseListener</code>.)
33+ * <P>
34+ * The class that is interested in processing a mouse motion event
35+ * either implements this interface (and all the methods it
36+ * contains) or extends the abstract <code>MouseMotionAdapter</code> class
37+ * (overriding only the methods of interest).
38+ * <P>
39+ * The listener object created from that class is then registered with a
40+ * component using the component's <code>addMouseMotionListener</code>
41+ * method. A mouse motion event is generated when the mouse is moved
42+ * or dragged. (Many such events will be generated). When a mouse motion event
43+ * occurs, the relevant method in the listener object is invoked, and
44+ * the <code>MouseEvent</code> is passed to it.
45+ *
46+ * @author Amy Fowler
47+ *
48+ * @see MouseMotionAdapter
49+ * @see MouseEvent
50+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/mousemotionlistener.html">Tutorial: Writing a Mouse Motion Listener</a>
51+ *
52+ * @since 1.1
53+ */
54+public interface MouseMotionListener extends EventListener {
55+
56+ /**
57+ * Invoked when a mouse button is pressed on a component and then
58+ * dragged. <code>MOUSE_DRAGGED</code> events will continue to be
59+ * delivered to the component where the drag originated until the
60+ * mouse button is released (regardless of whether the mouse position
61+ * is within the bounds of the component).
62+ * <p>
63+ * Due to platform-dependent Drag&Drop implementations,
64+ * <code>MOUSE_DRAGGED</code> events may not be delivered during a native
65+ * Drag&Drop operation.
66+ */
67+ public void mouseDragged(MouseEvent e);
68+
69+ /**
70+ * Invoked when the mouse cursor has been moved onto a component
71+ * but no buttons have been pushed.
72+ */
73+ public void mouseMoved(MouseEvent e);
74+
75+}
java/pkg/java/awt/event/MouseWheelEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/MouseWheelEvent.java+447−0
@@ -0,0 +1,447 @@
1+/*
2+ * Copyright (c) 2000, 2008, 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.event;
27+
28+import java.awt.Component;
29+
30+/**
31+ * An event which indicates that the mouse wheel was rotated in a component.
32+ * <P>
33+ * A wheel mouse is a mouse which has a wheel in place of the middle button.
34+ * This wheel can be rotated towards or away from the user. Mouse wheels are
35+ * most often used for scrolling, though other uses are possible.
36+ * <P>
37+ * A MouseWheelEvent object is passed to every <code>MouseWheelListener</code>
38+ * object which registered to receive the "interesting" mouse events using the
39+ * component's <code>addMouseWheelListener</code> method. Each such listener
40+ * object gets a <code>MouseEvent</code> containing the mouse event.
41+ * <P>
42+ * Due to the mouse wheel's special relationship to scrolling Components,
43+ * MouseWheelEvents are delivered somewhat differently than other MouseEvents.
44+ * This is because while other MouseEvents usually affect a change on
45+ * the Component directly under the mouse
46+ * cursor (for instance, when clicking a button), MouseWheelEvents often have
47+ * an effect away from the mouse cursor (moving the wheel while
48+ * over a Component inside a ScrollPane should scroll one of the
49+ * Scrollbars on the ScrollPane).
50+ * <P>
51+ * MouseWheelEvents start delivery from the Component underneath the
52+ * mouse cursor. If MouseWheelEvents are not enabled on the
53+ * Component, the event is delivered to the first ancestor
54+ * Container with MouseWheelEvents enabled. This will usually be
55+ * a ScrollPane with wheel scrolling enabled. The source
56+ * Component and x,y coordinates will be relative to the event's
57+ * final destination (the ScrollPane). This allows a complex
58+ * GUI to be installed without modification into a ScrollPane, and
59+ * for all MouseWheelEvents to be delivered to the ScrollPane for
60+ * scrolling.
61+ * <P>
62+ * Some AWT Components are implemented using native widgets which
63+ * display their own scrollbars and handle their own scrolling.
64+ * The particular Components for which this is true will vary from
65+ * platform to platform. When the mouse wheel is
66+ * moved over one of these Components, the event is delivered straight to
67+ * the native widget, and not propagated to ancestors.
68+ * <P>
69+ * Platforms offer customization of the amount of scrolling that
70+ * should take place when the mouse wheel is moved. The two most
71+ * common settings are to scroll a certain number of "units"
72+ * (commonly lines of text in a text-based component) or an entire "block"
73+ * (similar to page-up/page-down). The MouseWheelEvent offers
74+ * methods for conforming to the underlying platform settings. These
75+ * platform settings can be changed at any time by the user. MouseWheelEvents
76+ * reflect the most recent settings.
77+ * <P>
78+ * The <code>MouseWheelEvent</code> class includes methods for
79+ * getting the number of "clicks" by which the mouse wheel is rotated.
80+ * The {@link #getWheelRotation} method returns the integer number
81+ * of "clicks" corresponding to the number of notches by which the wheel was
82+ * rotated. In addition to this method, the <code>MouseWheelEvent</code>
83+ * class provides the {@link #getPreciseWheelRotation} method which returns
84+ * a double number of "clicks" in case a partial rotation occurred.
85+ * The {@link #getPreciseWheelRotation} method is useful if a mouse supports
86+ * a high-resolution wheel, such as a freely rotating wheel with no
87+ * notches. Applications can benefit by using this method to process
88+ * mouse wheel events more precisely, and thus, making visual perception
89+ * smoother.
90+ *
91+ * @author Brent Christian
92+ * @see MouseWheelListener
93+ * @see java.awt.ScrollPane
94+ * @see java.awt.ScrollPane#setWheelScrollingEnabled(boolean)
95+ * @see javax.swing.JScrollPane
96+ * @see javax.swing.JScrollPane#setWheelScrollingEnabled(boolean)
97+ * @since 1.4
98+ */
99+
100+public class MouseWheelEvent extends MouseEvent {
101+
102+ /**
103+ * Constant representing scrolling by "units" (like scrolling with the
104+ * arrow keys)
105+ *
106+ * @see #getScrollType
107+ */
108+ public static final int WHEEL_UNIT_SCROLL = 0;
109+
110+ /**
111+ * Constant representing scrolling by a "block" (like scrolling
112+ * with page-up, page-down keys)
113+ *
114+ * @see #getScrollType
115+ */
116+ public static final int WHEEL_BLOCK_SCROLL = 1;
117+
118+ /**
119+ * Indicates what sort of scrolling should take place in response to this
120+ * event, based on platform settings. Legal values are:
121+ * <ul>
122+ * <li> WHEEL_UNIT_SCROLL
123+ * <li> WHEEL_BLOCK_SCROLL
124+ * </ul>
125+ *
126+ * @see #getScrollType
127+ */
128+ int scrollType;
129+
130+ /**
131+ * Only valid for scrollType WHEEL_UNIT_SCROLL.
132+ * Indicates number of units that should be scrolled per
133+ * click of mouse wheel rotation, based on platform settings.
134+ *
135+ * @see #getScrollAmount
136+ * @see #getScrollType
137+ */
138+ int scrollAmount;
139+
140+ /**
141+ * Indicates how far the mouse wheel was rotated.
142+ *
143+ * @see #getWheelRotation
144+ */
145+ int wheelRotation;
146+
147+ /**
148+ * Indicates how far the mouse wheel was rotated.
149+ *
150+ * @see #getPreciseWheelRotation
151+ */
152+ double preciseWheelRotation;
153+
154+ /*
155+ * serialVersionUID
156+ */
157+
158+ private static final long serialVersionUID = 6459879390515399677L;
159+
160+ /**
161+ * Constructs a <code>MouseWheelEvent</code> object with the
162+ * specified source component, type, modifiers, coordinates,
163+ * scroll type, scroll amount, and wheel rotation.
164+ * <p>Absolute coordinates xAbs and yAbs are set to source's location on screen plus
165+ * relative coordinates x and y. xAbs and yAbs are set to zero if the source is not showing.
166+ * <p>Note that passing in an invalid <code>id</code> results in
167+ * unspecified behavior. This method throws an
168+ * <code>IllegalArgumentException</code> if <code>source</code>
169+ * is <code>null</code>.
170+ *
171+ * @param source the <code>Component</code> that originated
172+ * the event
173+ * @param id the integer that identifies the event
174+ * @param when a long that gives the time the event occurred
175+ * @param modifiers the modifier keys down during event
176+ * (shift, ctrl, alt, meta)
177+ * @param x the horizontal x coordinate for the mouse location
178+ * @param y the vertical y coordinate for the mouse location
179+ * @param clickCount the number of mouse clicks associated with event
180+ * @param popupTrigger a boolean, true if this event is a trigger for a
181+ * popup-menu
182+ * @param scrollType the type of scrolling which should take place in
183+ * response to this event; valid values are
184+ * <code>WHEEL_UNIT_SCROLL</code> and
185+ * <code>WHEEL_BLOCK_SCROLL</code>
186+ * @param scrollAmount for scrollType <code>WHEEL_UNIT_SCROLL</code>,
187+ * the number of units to be scrolled
188+ * @param wheelRotation the integer number of "clicks" by which the mouse
189+ * wheel was rotated
190+ *
191+ * @throws IllegalArgumentException if <code>source</code> is null
192+ * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, boolean)
193+ * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int)
194+ */
195+ public MouseWheelEvent (Component source, int id, long when, int modifiers,
196+ int x, int y, int clickCount, boolean popupTrigger,
197+ int scrollType, int scrollAmount, int wheelRotation) {
198+
199+ this(source, id, when, modifiers, x, y, 0, 0, clickCount,
200+ popupTrigger, scrollType, scrollAmount, wheelRotation);
201+ }
202+
203+ /**
204+ * Constructs a <code>MouseWheelEvent</code> object with the
205+ * specified source component, type, modifiers, coordinates,
206+ * absolute coordinates, scroll type, scroll amount, and wheel rotation.
207+ * <p>Note that passing in an invalid <code>id</code> results in
208+ * unspecified behavior. This method throws an
209+ * <code>IllegalArgumentException</code> if <code>source</code>
210+ * is <code>null</code>.<p>
211+ * Even if inconsistent values for relative and absolute coordinates are
212+ * passed to the constructor, the MouseWheelEvent instance is still
213+ * created and no exception is thrown.
214+ *
215+ * @param source the <code>Component</code> that originated
216+ * the event
217+ * @param id the integer that identifies the event
218+ * @param when a long that gives the time the event occurred
219+ * @param modifiers the modifier keys down during event
220+ * (shift, ctrl, alt, meta)
221+ * @param x the horizontal x coordinate for the mouse location
222+ * @param y the vertical y coordinate for the mouse location
223+ * @param xAbs the absolute horizontal x coordinate for the mouse location
224+ * @param yAbs the absolute vertical y coordinate for the mouse location
225+ * @param clickCount the number of mouse clicks associated with event
226+ * @param popupTrigger a boolean, true if this event is a trigger for a
227+ * popup-menu
228+ * @param scrollType the type of scrolling which should take place in
229+ * response to this event; valid values are
230+ * <code>WHEEL_UNIT_SCROLL</code> and
231+ * <code>WHEEL_BLOCK_SCROLL</code>
232+ * @param scrollAmount for scrollType <code>WHEEL_UNIT_SCROLL</code>,
233+ * the number of units to be scrolled
234+ * @param wheelRotation the integer number of "clicks" by which the mouse
235+ * wheel was rotated
236+ *
237+ * @throws IllegalArgumentException if <code>source</code> is null
238+ * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, boolean)
239+ * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int)
240+ * @since 1.6
241+ */
242+ public MouseWheelEvent (Component source, int id, long when, int modifiers,
243+ int x, int y, int xAbs, int yAbs, int clickCount, boolean popupTrigger,
244+ int scrollType, int scrollAmount, int wheelRotation) {
245+
246+ this(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount, popupTrigger,
247+ scrollType, scrollAmount, wheelRotation, wheelRotation);
248+
249+ }
250+
251+
252+ /**
253+ * Constructs a <code>MouseWheelEvent</code> object with the specified
254+ * source component, type, modifiers, coordinates, absolute coordinates,
255+ * scroll type, scroll amount, and wheel rotation.
256+ * <p>Note that passing in an invalid <code>id</code> parameter results
257+ * in unspecified behavior. This method throws an
258+ * <code>IllegalArgumentException</code> if <code>source</code> equals
259+ * <code>null</code>.
260+ * <p>Even if inconsistent values for relative and absolute coordinates
261+ * are passed to the constructor, a <code>MouseWheelEvent</code> instance
262+ * is still created and no exception is thrown.
263+ *
264+ * @param source the <code>Component</code> that originated the event
265+ * @param id the integer value that identifies the event
266+ * @param when a long value that gives the time when the event occurred
267+ * @param modifiers the modifier keys down during event
268+ * (shift, ctrl, alt, meta)
269+ * @param x the horizontal <code>x</code> coordinate for the
270+ * mouse location
271+ * @param y the vertical <code>y</code> coordinate for the
272+ * mouse location
273+ * @param xAbs the absolute horizontal <code>x</code> coordinate for
274+ * the mouse location
275+ * @param yAbs the absolute vertical <code>y</code> coordinate for
276+ * the mouse location
277+ * @param clickCount the number of mouse clicks associated with the event
278+ * @param popupTrigger a boolean value, <code>true</code> if this event is a trigger
279+ * for a popup-menu
280+ * @param scrollType the type of scrolling which should take place in
281+ * response to this event; valid values are
282+ * <code>WHEEL_UNIT_SCROLL</code> and
283+ * <code>WHEEL_BLOCK_SCROLL</code>
284+ * @param scrollAmount for scrollType <code>WHEEL_UNIT_SCROLL</code>,
285+ * the number of units to be scrolled
286+ * @param wheelRotation the integer number of "clicks" by which the mouse wheel
287+ * was rotated
288+ * @param preciseWheelRotation the double number of "clicks" by which the mouse wheel
289+ * was rotated
290+ *
291+ * @throws IllegalArgumentException if <code>source</code> is null
292+ * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, boolean)
293+ * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int)
294+ * @since 1.7
295+ */
296+ public MouseWheelEvent (Component source, int id, long when, int modifiers,
297+ int x, int y, int xAbs, int yAbs, int clickCount, boolean popupTrigger,
298+ int scrollType, int scrollAmount, int wheelRotation, double preciseWheelRotation) {
299+
300+ super(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount,
301+ popupTrigger, MouseEvent.NOBUTTON);
302+
303+ this.scrollType = scrollType;
304+ this.scrollAmount = scrollAmount;
305+ this.wheelRotation = wheelRotation;
306+ this.preciseWheelRotation = preciseWheelRotation;
307+
308+ }
309+
310+ /**
311+ * Returns the type of scrolling that should take place in response to this
312+ * event. This is determined by the native platform. Legal values are:
313+ * <ul>
314+ * <li> MouseWheelEvent.WHEEL_UNIT_SCROLL
315+ * <li> MouseWheelEvent.WHEEL_BLOCK_SCROLL
316+ * </ul>
317+ *
318+ * @return either MouseWheelEvent.WHEEL_UNIT_SCROLL or
319+ * MouseWheelEvent.WHEEL_BLOCK_SCROLL, depending on the configuration of
320+ * the native platform.
321+ * @see java.awt.Adjustable#getUnitIncrement
322+ * @see java.awt.Adjustable#getBlockIncrement
323+ * @see javax.swing.Scrollable#getScrollableUnitIncrement
324+ * @see javax.swing.Scrollable#getScrollableBlockIncrement
325+ */
326+ public int getScrollType() {
327+ return scrollType;
328+ }
329+
330+ /**
331+ * Returns the number of units that should be scrolled per
332+ * click of mouse wheel rotation.
333+ * Only valid if <code>getScrollType</code> returns
334+ * <code>MouseWheelEvent.WHEEL_UNIT_SCROLL</code>
335+ *
336+ * @return number of units to scroll, or an undefined value if
337+ * <code>getScrollType</code> returns
338+ * <code>MouseWheelEvent.WHEEL_BLOCK_SCROLL</code>
339+ * @see #getScrollType
340+ */
341+ public int getScrollAmount() {
342+ return scrollAmount;
343+ }
344+
345+ /**
346+ * Returns the number of "clicks" the mouse wheel was rotated, as an integer.
347+ * A partial rotation may occur if the mouse supports a high-resolution wheel.
348+ * In this case, the method returns zero until a full "click" has been accumulated.
349+ *
350+ * @return negative values if the mouse wheel was rotated up/away from
351+ * the user, and positive values if the mouse wheel was rotated down/
352+ * towards the user
353+ * @see #getPreciseWheelRotation
354+ */
355+ public int getWheelRotation() {
356+ return wheelRotation;
357+ }
358+
359+ /**
360+ * Returns the number of "clicks" the mouse wheel was rotated, as a double.
361+ * A partial rotation may occur if the mouse supports a high-resolution wheel.
362+ * In this case, the return value will include a fractional "click".
363+ *
364+ * @return negative values if the mouse wheel was rotated up or away from
365+ * the user, and positive values if the mouse wheel was rotated down or
366+ * towards the user
367+ * @see #getWheelRotation
368+ * @since 1.7
369+ */
370+ public double getPreciseWheelRotation() {
371+ return preciseWheelRotation;
372+ }
373+
374+ /**
375+ * This is a convenience method to aid in the implementation of
376+ * the common-case MouseWheelListener - to scroll a ScrollPane or
377+ * JScrollPane by an amount which conforms to the platform settings.
378+ * (Note, however, that <code>ScrollPane</code> and
379+ * <code>JScrollPane</code> already have this functionality built in.)
380+ * <P>
381+ * This method returns the number of units to scroll when scroll type is
382+ * MouseWheelEvent.WHEEL_UNIT_SCROLL, and should only be called if
383+ * <code>getScrollType</code> returns MouseWheelEvent.WHEEL_UNIT_SCROLL.
384+ * <P>
385+ * Direction of scroll, amount of wheel movement,
386+ * and platform settings for wheel scrolling are all accounted for.
387+ * This method does not and cannot take into account value of the
388+ * Adjustable/Scrollable unit increment, as this will vary among
389+ * scrolling components.
390+ * <P>
391+ * A simplified example of how this method might be used in a
392+ * listener:
393+ * <pre>
394+ * mouseWheelMoved(MouseWheelEvent event) {
395+ * ScrollPane sp = getScrollPaneFromSomewhere();
396+ * Adjustable adj = sp.getVAdjustable()
397+ * if (MouseWheelEvent.getScrollType() == WHEEL_UNIT_SCROLL) {
398+ * int totalScrollAmount =
399+ * event.getUnitsToScroll() *
400+ * adj.getUnitIncrement();
401+ * adj.setValue(adj.getValue() + totalScrollAmount);
402+ * }
403+ * }
404+ * </pre>
405+ *
406+ * @return the number of units to scroll based on the direction and amount
407+ * of mouse wheel rotation, and on the wheel scrolling settings of the
408+ * native platform
409+ * @see #getScrollType
410+ * @see #getScrollAmount
411+ * @see MouseWheelListener
412+ * @see java.awt.Adjustable
413+ * @see java.awt.Adjustable#getUnitIncrement
414+ * @see javax.swing.Scrollable
415+ * @see javax.swing.Scrollable#getScrollableUnitIncrement
416+ * @see java.awt.ScrollPane
417+ * @see java.awt.ScrollPane#setWheelScrollingEnabled
418+ * @see javax.swing.JScrollPane
419+ * @see javax.swing.JScrollPane#setWheelScrollingEnabled
420+ */
421+ public int getUnitsToScroll() {
422+ return scrollAmount * wheelRotation;
423+ }
424+
425+ /**
426+ * Returns a parameter string identifying this event.
427+ * This method is useful for event-logging and for debugging.
428+ *
429+ * @return a string identifying the event and its attributes
430+ */
431+ public String paramString() {
432+ String scrollTypeStr = null;
433+
434+ if (getScrollType() == WHEEL_UNIT_SCROLL) {
435+ scrollTypeStr = "WHEEL_UNIT_SCROLL";
436+ }
437+ else if (getScrollType() == WHEEL_BLOCK_SCROLL) {
438+ scrollTypeStr = "WHEEL_BLOCK_SCROLL";
439+ }
440+ else {
441+ scrollTypeStr = "unknown scroll type";
442+ }
443+ return super.paramString()+",scrollType="+scrollTypeStr+
444+ ",scrollAmount="+getScrollAmount()+",wheelRotation="+
445+ getWheelRotation()+",preciseWheelRotation="+getPreciseWheelRotation();
446+ }
447+}
java/pkg/java/awt/event/MouseWheelListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/MouseWheelListener.java+58−0
@@ -0,0 +1,58 @@
1+/*
2+ * Copyright (c) 2000, 2003, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving mouse wheel events on a component.
32+ * (For clicks and other mouse events, use the <code>MouseListener</code>.
33+ * For mouse movement and drags, use the <code>MouseMotionListener</code>.)
34+ * <P>
35+ * The class that is interested in processing a mouse wheel event
36+ * implements this interface (and all the methods it contains).
37+ * <P>
38+ * The listener object created from that class is then registered with a
39+ * component using the component's <code>addMouseWheelListener</code>
40+ * method. A mouse wheel event is generated when the mouse wheel is rotated.
41+ * When a mouse wheel event occurs, that object's <code>mouseWheelMoved</code>
42+ * method is invoked.
43+ * <p>
44+ * For information on how mouse wheel events are dispatched, see
45+ * the class description for {@link MouseWheelEvent}.
46+ *
47+ * @author Brent Christian
48+ * @see MouseWheelEvent
49+ * @since 1.4
50+ */
51+public interface MouseWheelListener extends EventListener {
52+
53+ /**
54+ * Invoked when the mouse wheel is rotated.
55+ * @see MouseWheelEvent
56+ */
57+ public void mouseWheelMoved(MouseWheelEvent e);
58+}
java/pkg/java/awt/event/NativeLibLoader.class+0−0

Binary file not shown.

java/pkg/java/awt/event/NativeLibLoader.java+59−0
@@ -0,0 +1,59 @@
1+/*
2+ * Copyright (c) 1998, 2002, 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.event;
27+
28+class NativeLibLoader {
29+
30+ /**
31+ * This is copied from java.awt.Toolkit since we need the library
32+ * loaded in sun.awt.image also:
33+ *
34+ * WARNING: This is a temporary workaround for a problem in the
35+ * way the AWT loads native libraries. A number of classes in this
36+ * package (sun.awt.image) have a native method, initIDs(),
37+ * which initializes
38+ * the JNI field and method ids used in the native portion of
39+ * their implementation.
40+ *
41+ * Since the use and storage of these ids is done by the
42+ * implementation libraries, the implementation of these method is
43+ * provided by the particular AWT implementations (for example,
44+ * "Toolkit"s/Peer), such as Motif, Microsoft Windows, or Tiny. The
45+ * problem is that this means that the native libraries must be
46+ * loaded by the java.* classes, which do not necessarily know the
47+ * names of the libraries to load. A better way of doing this
48+ * would be to provide a separate library which defines java.awt.*
49+ * initIDs, and exports the relevant symbols out to the
50+ * implementation libraries.
51+ *
52+ * For now, we know it's done by the implementation, and we assume
53+ * that the name of the library is "awt". -br.
54+ */
55+ static void loadLibraries() {
56+ java.security.AccessController.doPrivileged(
57+ new sun.security.action.LoadLibraryAction("awt"));
58+ }
59+}
java/pkg/java/awt/event/PaintEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/PaintEvent.java+139−0
@@ -0,0 +1,139 @@
1+/*
2+ * Copyright (c) 1996, 2008, 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.event;
27+
28+import java.awt.Component;
29+import java.awt.Rectangle;
30+
31+/**
32+ * The component-level paint event.
33+ * This event is a special type which is used to ensure that
34+ * paint/update method calls are serialized along with the other
35+ * events delivered from the event queue. This event is not
36+ * designed to be used with the Event Listener model; programs
37+ * should continue to override paint/update methods in order
38+ * render themselves properly.
39+ * <p>
40+ * An unspecified behavior will be caused if the {@code id} parameter
41+ * of any particular {@code PaintEvent} instance is not
42+ * in the range from {@code PAINT_FIRST} to {@code PAINT_LAST}.
43+ *
44+ * @author Amy Fowler
45+ * @since 1.1
46+ */
47+public class PaintEvent extends ComponentEvent {
48+
49+ /**
50+ * Marks the first integer id for the range of paint event ids.
51+ */
52+ public static final int PAINT_FIRST = 800;
53+
54+ /**
55+ * Marks the last integer id for the range of paint event ids.
56+ */
57+ public static final int PAINT_LAST = 801;
58+
59+ /**
60+ * The paint event type.
61+ */
62+ public static final int PAINT = PAINT_FIRST;
63+
64+ /**
65+ * The update event type.
66+ */
67+ public static final int UPDATE = PAINT_FIRST + 1; //801
68+
69+ /**
70+ * This is the rectangle that represents the area on the source
71+ * component that requires a repaint.
72+ * This rectangle should be non null.
73+ *
74+ * @serial
75+ * @see java.awt.Rectangle
76+ * @see #setUpdateRect(Rectangle)
77+ * @see #getUpdateRect()
78+ */
79+ Rectangle updateRect;
80+
81+ /*
82+ * JDK 1.1 serialVersionUID
83+ */
84+ private static final long serialVersionUID = 1267492026433337593L;
85+
86+ /**
87+ * Constructs a <code>PaintEvent</code> object with the specified
88+ * source component and type.
89+ * <p> This method throws an
90+ * <code>IllegalArgumentException</code> if <code>source</code>
91+ * is <code>null</code>.
92+ *
93+ * @param source The object where the event originated
94+ * @param id The integer that identifies the event type.
95+ * For information on allowable values, see
96+ * the class description for {@link PaintEvent}
97+ * @param updateRect The rectangle area which needs to be repainted
98+ * @throws IllegalArgumentException if <code>source</code> is null
99+ * @see #getSource()
100+ * @see #getID()
101+ * @see #getUpdateRect()
102+ */
103+ public PaintEvent(Component source, int id, Rectangle updateRect) {
104+ super(source, id);
105+ this.updateRect = updateRect;
106+ }
107+
108+ /**
109+ * Returns the rectangle representing the area which needs to be
110+ * repainted in response to this event.
111+ */
112+ public Rectangle getUpdateRect() {
113+ return updateRect;
114+ }
115+
116+ /**
117+ * Sets the rectangle representing the area which needs to be
118+ * repainted in response to this event.
119+ * @param updateRect the rectangle area which needs to be repainted
120+ */
121+ public void setUpdateRect(Rectangle updateRect) {
122+ this.updateRect = updateRect;
123+ }
124+
125+ public String paramString() {
126+ String typeStr;
127+ switch(id) {
128+ case PAINT:
129+ typeStr = "PAINT";
130+ break;
131+ case UPDATE:
132+ typeStr = "UPDATE";
133+ break;
134+ default:
135+ typeStr = "unknown type";
136+ }
137+ return typeStr + ",updateRect="+(updateRect != null ? updateRect.toString() : "null");
138+ }
139+}
java/pkg/java/awt/event/TextEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/TextEvent.java+113−0
@@ -0,0 +1,113 @@
1+/*
2+ * Copyright (c) 1996, 2008, 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.event;
27+
28+import java.awt.AWTEvent;
29+
30+/**
31+ * A semantic event which indicates that an object's text changed.
32+ * This high-level event is generated by an object (such as a TextComponent)
33+ * when its text changes. The event is passed to
34+ * every <code>TextListener</code> object which registered to receive such
35+ * events using the component's <code>addTextListener</code> method.
36+ * <P>
37+ * The object that implements the <code>TextListener</code> interface gets
38+ * this <code>TextEvent</code> when the event occurs. The listener is
39+ * spared the details of processing individual mouse movements and key strokes
40+ * Instead, it can process a "meaningful" (semantic) event like "text changed".
41+ * <p>
42+ * An unspecified behavior will be caused if the {@code id} parameter
43+ * of any particular {@code TextEvent} instance is not
44+ * in the range from {@code TEXT_FIRST} to {@code TEXT_LAST}.
45+ *
46+ * @author Georges Saab
47+ *
48+ * @see java.awt.TextComponent
49+ * @see TextListener
50+ *
51+ * @since 1.1
52+ */
53+
54+public class TextEvent extends AWTEvent {
55+
56+ /**
57+ * The first number in the range of ids used for text events.
58+ */
59+ public static final int TEXT_FIRST = 900;
60+
61+ /**
62+ * The last number in the range of ids used for text events.
63+ */
64+ public static final int TEXT_LAST = 900;
65+
66+ /**
67+ * This event id indicates that object's text changed.
68+ */
69+ public static final int TEXT_VALUE_CHANGED = TEXT_FIRST;
70+
71+ /*
72+ * JDK 1.1 serialVersionUID
73+ */
74+ private static final long serialVersionUID = 6269902291250941179L;
75+
76+ /**
77+ * Constructs a <code>TextEvent</code> object.
78+ * <p> This method throws an
79+ * <code>IllegalArgumentException</code> if <code>source</code>
80+ * is <code>null</code>.
81+ *
82+ * @param source The (<code>TextComponent</code>) object that
83+ * originated the event
84+ * @param id An integer that identifies the event type.
85+ * For information on allowable values, see
86+ * the class description for {@link TextEvent}
87+ * @throws IllegalArgumentException if <code>source</code> is null
88+ * @see #getSource()
89+ * @see #getID()
90+ */
91+ public TextEvent(Object source, int id) {
92+ super(source, id);
93+ }
94+
95+
96+ /**
97+ * Returns a parameter string identifying this text event.
98+ * This method is useful for event-logging and for debugging.
99+ *
100+ * @return a string identifying the event and its attributes
101+ */
102+ public String paramString() {
103+ String typeStr;
104+ switch(id) {
105+ case TEXT_VALUE_CHANGED:
106+ typeStr = "TEXT_VALUE_CHANGED";
107+ break;
108+ default:
109+ typeStr = "unknown type";
110+ }
111+ return typeStr;
112+ }
113+}
java/pkg/java/awt/event/TextListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/TextListener.java+55−0
@@ -0,0 +1,55 @@
1+/*
2+ * Copyright (c) 1996, 2008, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving text events.
32+ *
33+ * The class that is interested in processing a text event
34+ * implements this interface. The object created with that
35+ * class is then registered with a component using the
36+ * component's <code>addTextListener</code> method. When the
37+ * component's text changes, the listener object's
38+ * <code>textValueChanged</code> method is invoked.
39+ *
40+ * @author Georges Saab
41+ *
42+ * @see TextEvent
43+ *
44+ * @since 1.1
45+ */
46+public interface TextListener extends EventListener {
47+
48+ /**
49+ * Invoked when the value of the text has changed.
50+ * The code written for this method performs the operations
51+ * that need to occur when text changes.
52+ */
53+ public void textValueChanged(TextEvent e);
54+
55+}
java/pkg/java/awt/event/WindowAdapter.class+0−0

Binary file not shown.

java/pkg/java/awt/event/WindowAdapter.java+117−0
@@ -0,0 +1,117 @@
1+/*
2+ * Copyright (c) 1996, 2006, 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.event;
27+
28+/**
29+ * An abstract adapter class for receiving window events.
30+ * The methods in this class are empty. This class exists as
31+ * convenience for creating listener objects.
32+ * <P>
33+ * Extend this class to create a <code>WindowEvent</code> listener
34+ * and override the methods for the events of interest. (If you implement the
35+ * <code>WindowListener</code> interface, you have to define all of
36+ * the methods in it. This abstract class defines null methods for them
37+ * all, so you can only have to define methods for events you care about.)
38+ * <P>
39+ * Create a listener object using the extended class and then register it with
40+ * a Window using the window's <code>addWindowListener</code>
41+ * method. When the window's status changes by virtue of being opened,
42+ * closed, activated or deactivated, iconified or deiconified,
43+ * the relevant method in the listener
44+ * object is invoked, and the <code>WindowEvent</code> is passed to it.
45+ *
46+ * @see WindowEvent
47+ * @see WindowListener
48+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/windowlistener.html">Tutorial: Writing a Window Listener</a>
49+ *
50+ * @author Carl Quinn
51+ * @author Amy Fowler
52+ * @author David Mendenhall
53+ * @since 1.1
54+ */
55+public abstract class WindowAdapter
56+ implements WindowListener, WindowStateListener, WindowFocusListener
57+{
58+ /**
59+ * Invoked when a window has been opened.
60+ */
61+ public void windowOpened(WindowEvent e) {}
62+
63+ /**
64+ * Invoked when a window is in the process of being closed.
65+ * The close operation can be overridden at this point.
66+ */
67+ public void windowClosing(WindowEvent e) {}
68+
69+ /**
70+ * Invoked when a window has been closed.
71+ */
72+ public void windowClosed(WindowEvent e) {}
73+
74+ /**
75+ * Invoked when a window is iconified.
76+ */
77+ public void windowIconified(WindowEvent e) {}
78+
79+ /**
80+ * Invoked when a window is de-iconified.
81+ */
82+ public void windowDeiconified(WindowEvent e) {}
83+
84+ /**
85+ * Invoked when a window is activated.
86+ */
87+ public void windowActivated(WindowEvent e) {}
88+
89+ /**
90+ * Invoked when a window is de-activated.
91+ */
92+ public void windowDeactivated(WindowEvent e) {}
93+
94+ /**
95+ * Invoked when a window state is changed.
96+ * @since 1.4
97+ */
98+ public void windowStateChanged(WindowEvent e) {}
99+
100+ /**
101+ * Invoked when the Window is set to be the focused Window, which means
102+ * that the Window, or one of its subcomponents, will receive keyboard
103+ * events.
104+ *
105+ * @since 1.4
106+ */
107+ public void windowGainedFocus(WindowEvent e) {}
108+
109+ /**
110+ * Invoked when the Window is no longer the focused Window, which means
111+ * that keyboard events will no longer be delivered to the Window or any of
112+ * its subcomponents.
113+ *
114+ * @since 1.4
115+ */
116+ public void windowLostFocus(WindowEvent e) {}
117+}
java/pkg/java/awt/event/WindowEvent.class+0−0

Binary file not shown.

java/pkg/java/awt/event/WindowEvent.java+428−0
@@ -0,0 +1,428 @@
1+/*
2+ * Copyright (c) 1996, 2008, 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.event;
27+
28+import java.awt.Window;
29+import sun.awt.AppContext;
30+import sun.awt.SunToolkit;
31+
32+/**
33+ * A low-level event that indicates that a window has changed its status. This
34+ * low-level event is generated by a Window object when it is opened, closed,
35+ * activated, deactivated, iconified, or deiconified, or when focus is
36+ * transfered into or out of the Window.
37+ * <P>
38+ * The event is passed to every <code>WindowListener</code>
39+ * or <code>WindowAdapter</code> object which registered to receive such
40+ * events using the window's <code>addWindowListener</code> method.
41+ * (<code>WindowAdapter</code> objects implement the
42+ * <code>WindowListener</code> interface.) Each such listener object
43+ * gets this <code>WindowEvent</code> when the event occurs.
44+ * <p>
45+ * An unspecified behavior will be caused if the {@code id} parameter
46+ * of any particular {@code WindowEvent} instance is not
47+ * in the range from {@code WINDOW_FIRST} to {@code WINDOW_LAST}.
48+ *
49+ * @author Carl Quinn
50+ * @author Amy Fowler
51+ *
52+ * @see WindowAdapter
53+ * @see WindowListener
54+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/windowlistener.html">Tutorial: Writing a Window Listener</a>
55+ *
56+ * @since JDK1.1
57+ */
58+public class WindowEvent extends ComponentEvent {
59+
60+ /**
61+ * The first number in the range of ids used for window events.
62+ */
63+ public static final int WINDOW_FIRST = 200;
64+
65+ /**
66+ * The window opened event. This event is delivered only
67+ * the first time a window is made visible.
68+ */
69+ public static final int WINDOW_OPENED = WINDOW_FIRST; // 200
70+
71+ /**
72+ * The "window is closing" event. This event is delivered when
73+ * the user attempts to close the window from the window's system menu.
74+ * If the program does not explicitly hide or dispose the window
75+ * while processing this event, the window close operation will be
76+ * cancelled.
77+ */
78+ public static final int WINDOW_CLOSING = 1 + WINDOW_FIRST; //Event.WINDOW_DESTROY
79+
80+ /**
81+ * The window closed event. This event is delivered after
82+ * the window has been closed as the result of a call to dispose.
83+ */
84+ public static final int WINDOW_CLOSED = 2 + WINDOW_FIRST;
85+
86+ /**
87+ * The window iconified event. This event is delivered when
88+ * the window has been changed from a normal to a minimized state.
89+ * For many platforms, a minimized window is displayed as
90+ * the icon specified in the window's iconImage property.
91+ * @see java.awt.Frame#setIconImage
92+ */
93+ public static final int WINDOW_ICONIFIED = 3 + WINDOW_FIRST; //Event.WINDOW_ICONIFY
94+
95+ /**
96+ * The window deiconified event type. This event is delivered when
97+ * the window has been changed from a minimized to a normal state.
98+ */
99+ public static final int WINDOW_DEICONIFIED = 4 + WINDOW_FIRST; //Event.WINDOW_DEICONIFY
100+
101+ /**
102+ * The window-activated event type. This event is delivered when the Window
103+ * becomes the active Window. Only a Frame or a Dialog can be the active
104+ * Window. The native windowing system may denote the active Window or its
105+ * children with special decorations, such as a highlighted title bar. The
106+ * active Window is always either the focused Window, or the first Frame or
107+ * Dialog that is an owner of the focused Window.
108+ */
109+ public static final int WINDOW_ACTIVATED = 5 + WINDOW_FIRST;
110+
111+ /**
112+ * The window-deactivated event type. This event is delivered when the
113+ * Window is no longer the active Window. Only a Frame or a Dialog can be
114+ * the active Window. The native windowing system may denote the active
115+ * Window or its children with special decorations, such as a highlighted
116+ * title bar. The active Window is always either the focused Window, or the
117+ * first Frame or Dialog that is an owner of the focused Window.
118+ */
119+ public static final int WINDOW_DEACTIVATED = 6 + WINDOW_FIRST;
120+
121+ /**
122+ * The window-gained-focus event type. This event is delivered when the
123+ * Window becomes the focused Window, which means that the Window, or one
124+ * of its subcomponents, will receive keyboard events.
125+ */
126+ public static final int WINDOW_GAINED_FOCUS = 7 + WINDOW_FIRST;
127+
128+ /**
129+ * The window-lost-focus event type. This event is delivered when a Window
130+ * is no longer the focused Window, which means keyboard events will no
131+ * longer be delivered to the Window or any of its subcomponents.
132+ */
133+ public static final int WINDOW_LOST_FOCUS = 8 + WINDOW_FIRST;
134+
135+ /**
136+ * The window-state-changed event type. This event is delivered
137+ * when a Window's state is changed by virtue of it being
138+ * iconified, maximized etc.
139+ * @since 1.4
140+ */
141+ public static final int WINDOW_STATE_CHANGED = 9 + WINDOW_FIRST;
142+
143+ /**
144+ * The last number in the range of ids used for window events.
145+ */
146+ public static final int WINDOW_LAST = WINDOW_STATE_CHANGED;
147+
148+ /**
149+ * The other Window involved in this focus or activation change. For a
150+ * WINDOW_ACTIVATED or WINDOW_GAINED_FOCUS event, this is the Window that
151+ * lost activation or focus. For a WINDOW_DEACTIVATED or WINDOW_LOST_FOCUS
152+ * event, this is the Window that gained activation or focus. For any other
153+ * type of WindowEvent, or if the focus or activation change occurs with a
154+ * native application, a Java application in a different VM, or with no
155+ * other Window, null is returned.
156+ *
157+ * @see #getOppositeWindow
158+ * @since 1.4
159+ */
160+ transient Window opposite;
161+
162+ /**
163+ * TBS
164+ */
165+ int oldState;
166+ int newState;
167+
168+
169+ /*
170+ * JDK 1.1 serialVersionUID
171+ */
172+ private static final long serialVersionUID = -1567959133147912127L;
173+
174+
175+ /**
176+ * Constructs a <code>WindowEvent</code> object.
177+ * <p>This method throws an
178+ * <code>IllegalArgumentException</code> if <code>source</code>
179+ * is <code>null</code>.
180+ *
181+ * @param source The <code>Window</code> object
182+ * that originated the event
183+ * @param id An integer indicating the type of event.
184+ * For information on allowable values, see
185+ * the class description for {@link WindowEvent}
186+ * @param opposite The other window involved in the focus or activation
187+ * change, or <code>null</code>
188+ * @param oldState Previous state of the window for window state change event.
189+ * See {@code #getOldState()} for allowable values
190+ * @param newState New state of the window for window state change event.
191+ * See {@code #getNewState()} for allowable values
192+ * @throws IllegalArgumentException if <code>source</code> is null
193+ * @see #getWindow()
194+ * @see #getID()
195+ * @see #getOppositeWindow()
196+ * @see #getOldState()
197+ * @see #getNewState()
198+ * @since 1.4
199+ */
200+ public WindowEvent(Window source, int id, Window opposite,
201+ int oldState, int newState)
202+ {
203+ super(source, id);
204+ this.opposite = opposite;
205+ this.oldState = oldState;
206+ this.newState = newState;
207+ }
208+
209+ /**
210+ * Constructs a <code>WindowEvent</code> object with the
211+ * specified opposite <code>Window</code>. The opposite
212+ * <code>Window</code> is the other <code>Window</code>
213+ * involved in this focus or activation change.
214+ * For a <code>WINDOW_ACTIVATED</code> or
215+ * <code>WINDOW_GAINED_FOCUS</code> event, this is the
216+ * <code>Window</code> that lost activation or focus.
217+ * For a <code>WINDOW_DEACTIVATED</code> or
218+ * <code>WINDOW_LOST_FOCUS</code> event, this is the
219+ * <code>Window</code> that gained activation or focus.
220+ * If this focus change occurs with a native application, with a
221+ * Java application in a different VM, or with no other
222+ * <code>Window</code>, then the opposite Window is <code>null</code>.
223+ * <p>This method throws an
224+ * <code>IllegalArgumentException</code> if <code>source</code>
225+ * is <code>null</code>.
226+ *
227+ * @param source The <code>Window</code> object that
228+ * originated the event
229+ * @param id An integer indicating the type of event.
230+ * For information on allowable values, see
231+ * the class description for {@link WindowEvent}.
232+ * It is expected that this constructor will not
233+ * be used for other then
234+ * {@code WINDOW_ACTIVATED},{@code WINDOW_DEACTIVATED},
235+ * {@code WINDOW_GAINED_FOCUS}, or {@code WINDOW_LOST_FOCUS}.
236+ * {@code WindowEvent} types,
237+ * because the opposite <code>Window</code> of other event types
238+ * will always be {@code null}.
239+ * @param opposite The other <code>Window</code> involved in the
240+ * focus or activation change, or <code>null</code>
241+ * @throws IllegalArgumentException if <code>source</code> is null
242+ * @see #getWindow()
243+ * @see #getID()
244+ * @see #getOppositeWindow()
245+ * @since 1.4
246+ */
247+ public WindowEvent(Window source, int id, Window opposite) {
248+ this(source, id, opposite, 0, 0);
249+ }
250+
251+ /**
252+ * Constructs a <code>WindowEvent</code> object with the specified
253+ * previous and new window states.
254+ * <p>This method throws an
255+ * <code>IllegalArgumentException</code> if <code>source</code>
256+ * is <code>null</code>.
257+ *
258+ * @param source The <code>Window</code> object
259+ * that originated the event
260+ * @param id An integer indicating the type of event.
261+ * For information on allowable values, see
262+ * the class description for {@link WindowEvent}.
263+ * It is expected that this constructor will not
264+ * be used for other then
265+ * {@code WINDOW_STATE_CHANGED}
266+ * {@code WindowEvent}
267+ * types, because the previous and new window
268+ * states are meaningless for other event types.
269+ * @param oldState An integer representing the previous window state.
270+ * See {@code #getOldState()} for allowable values
271+ * @param newState An integer representing the new window state.
272+ * See {@code #getNewState()} for allowable values
273+ * @throws IllegalArgumentException if <code>source</code> is null
274+ * @see #getWindow()
275+ * @see #getID()
276+ * @see #getOldState()
277+ * @see #getNewState()
278+ * @since 1.4
279+ */
280+ public WindowEvent(Window source, int id, int oldState, int newState) {
281+ this(source, id, null, oldState, newState);
282+ }
283+
284+ /**
285+ * Constructs a <code>WindowEvent</code> object.
286+ * <p>This method throws an
287+ * <code>IllegalArgumentException</code> if <code>source</code>
288+ * is <code>null</code>.
289+ *
290+ * @param source The <code>Window</code> object that originated the event
291+ * @param id An integer indicating the type of event.
292+ * For information on allowable values, see
293+ * the class description for {@link WindowEvent}.
294+ * @throws IllegalArgumentException if <code>source</code> is null
295+ * @see #getWindow()
296+ * @see #getID()
297+ */
298+ public WindowEvent(Window source, int id) {
299+ this(source, id, null, 0, 0);
300+ }
301+
302+ /**
303+ * Returns the originator of the event.
304+ *
305+ * @return the Window object that originated the event
306+ */
307+ public Window getWindow() {
308+ return (source instanceof Window) ? (Window)source : null;
309+ }
310+
311+ /**
312+ * Returns the other Window involved in this focus or activation change.
313+ * For a WINDOW_ACTIVATED or WINDOW_GAINED_FOCUS event, this is the Window
314+ * that lost activation or focus. For a WINDOW_DEACTIVATED or
315+ * WINDOW_LOST_FOCUS event, this is the Window that gained activation or
316+ * focus. For any other type of WindowEvent, or if the focus or activation
317+ * change occurs with a native application, with a Java application in a
318+ * different VM or context, or with no other Window, null is returned.
319+ *
320+ * @return the other Window involved in the focus or activation change, or
321+ * null
322+ * @since 1.4
323+ */
324+ public Window getOppositeWindow() {
325+ if (opposite == null) {
326+ return null;
327+ }
328+
329+ return (SunToolkit.targetToAppContext(opposite) ==
330+ AppContext.getAppContext())
331+ ? opposite
332+ : null;
333+ }
334+
335+ /**
336+ * For <code>WINDOW_STATE_CHANGED</code> events returns the
337+ * previous state of the window. The state is
338+ * represented as a bitwise mask.
339+ * <ul>
340+ * <li><code>NORMAL</code>
341+ * <br>Indicates that no state bits are set.
342+ * <li><code>ICONIFIED</code>
343+ * <li><code>MAXIMIZED_HORIZ</code>
344+ * <li><code>MAXIMIZED_VERT</code>
345+ * <li><code>MAXIMIZED_BOTH</code>
346+ * <br>Concatenates <code>MAXIMIZED_HORIZ</code>
347+ * and <code>MAXIMIZED_VERT</code>.
348+ * </ul>
349+ *
350+ * @return a bitwise mask of the previous window state
351+ * @see java.awt.Frame#getExtendedState()
352+ * @since 1.4
353+ */
354+ public int getOldState() {
355+ return oldState;
356+ }
357+
358+ /**
359+ * For <code>WINDOW_STATE_CHANGED</code> events returns the
360+ * new state of the window. The state is
361+ * represented as a bitwise mask.
362+ * <ul>
363+ * <li><code>NORMAL</code>
364+ * <br>Indicates that no state bits are set.
365+ * <li><code>ICONIFIED</code>
366+ * <li><code>MAXIMIZED_HORIZ</code>
367+ * <li><code>MAXIMIZED_VERT</code>
368+ * <li><code>MAXIMIZED_BOTH</code>
369+ * <br>Concatenates <code>MAXIMIZED_HORIZ</code>
370+ * and <code>MAXIMIZED_VERT</code>.
371+ * </ul>
372+ *
373+ * @return a bitwise mask of the new window state
374+ * @see java.awt.Frame#getExtendedState()
375+ * @since 1.4
376+ */
377+ public int getNewState() {
378+ return newState;
379+ }
380+
381+ /**
382+ * Returns a parameter string identifying this event.
383+ * This method is useful for event-logging and for debugging.
384+ *
385+ * @return a string identifying the event and its attributes
386+ */
387+ public String paramString() {
388+ String typeStr;
389+ switch(id) {
390+ case WINDOW_OPENED:
391+ typeStr = "WINDOW_OPENED";
392+ break;
393+ case WINDOW_CLOSING:
394+ typeStr = "WINDOW_CLOSING";
395+ break;
396+ case WINDOW_CLOSED:
397+ typeStr = "WINDOW_CLOSED";
398+ break;
399+ case WINDOW_ICONIFIED:
400+ typeStr = "WINDOW_ICONIFIED";
401+ break;
402+ case WINDOW_DEICONIFIED:
403+ typeStr = "WINDOW_DEICONIFIED";
404+ break;
405+ case WINDOW_ACTIVATED:
406+ typeStr = "WINDOW_ACTIVATED";
407+ break;
408+ case WINDOW_DEACTIVATED:
409+ typeStr = "WINDOW_DEACTIVATED";
410+ break;
411+ case WINDOW_GAINED_FOCUS:
412+ typeStr = "WINDOW_GAINED_FOCUS";
413+ break;
414+ case WINDOW_LOST_FOCUS:
415+ typeStr = "WINDOW_LOST_FOCUS";
416+ break;
417+ case WINDOW_STATE_CHANGED:
418+ typeStr = "WINDOW_STATE_CHANGED";
419+ break;
420+ default:
421+ typeStr = "unknown type";
422+ }
423+ typeStr += ",opposite=" + getOppositeWindow()
424+ + ",oldState=" + oldState + ",newState=" + newState;
425+
426+ return typeStr;
427+ }
428+}
java/pkg/java/awt/event/WindowFocusListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/WindowFocusListener.java+69−0
@@ -0,0 +1,69 @@
1+/*
2+ * Copyright (c) 2000, 2006, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving <code>WindowEvents</code>, including
32+ * <code>WINDOW_GAINED_FOCUS</code> and <code>WINDOW_LOST_FOCUS</code> events.
33+ * The class that is interested in processing a <code>WindowEvent</code>
34+ * either implements this interface (and
35+ * all the methods it contains) or extends the abstract
36+ * <code>WindowAdapter</code> class (overriding only the methods of interest).
37+ * The listener object created from that class is then registered with a
38+ * <code>Window</code>
39+ * using the <code>Window</code>'s <code>addWindowFocusListener</code> method.
40+ * When the <code>Window</code>'s
41+ * status changes by virtue of it being opened, closed, activated, deactivated,
42+ * iconified, or deiconified, or by focus being transfered into or out of the
43+ * <code>Window</code>, the relevant method in the listener object is invoked,
44+ * and the <code>WindowEvent</code> is passed to it.
45+ *
46+ * @author David Mendenhall
47+ *
48+ * @see WindowAdapter
49+ * @see WindowEvent
50+ * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/windowlistener.html">Tutorial: Writing a Window Listener</a>
51+ *
52+ * @since 1.4
53+ */
54+public interface WindowFocusListener extends EventListener {
55+
56+ /**
57+ * Invoked when the Window is set to be the focused Window, which means
58+ * that the Window, or one of its subcomponents, will receive keyboard
59+ * events.
60+ */
61+ public void windowGainedFocus(WindowEvent e);
62+
63+ /**
64+ * Invoked when the Window is no longer the focused Window, which means
65+ * that keyboard events will no longer be delivered to the Window or any of
66+ * its subcomponents.
67+ */
68+ public void windowLostFocus(WindowEvent e);
69+}
java/pkg/java/awt/event/WindowListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/WindowListener.java+103−0
@@ -0,0 +1,103 @@
1+/*
2+ * Copyright (c) 1996, 2003, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving window events.
32+ * The class that is interested in processing a window event
33+ * either implements this interface (and all the methods it
34+ * contains) or extends the abstract <code>WindowAdapter</code> class
35+ * (overriding only the methods of interest).
36+ * The listener object created from that class is then registered with a
37+ * Window using the window's <code>addWindowListener</code>
38+ * method. When the window's status changes by virtue of being opened,
39+ * closed, activated or deactivated, iconified or deiconified,
40+ * the relevant method in the listener object is invoked, and the
41+ * <code>WindowEvent</code> is passed to it.
42+ *
43+ * @author Carl Quinn
44+ *
45+ * @see WindowAdapter
46+ * @see WindowEvent
47+ * @see <a href="http://java.sun.com/docs/books/tutorial/uiswing/events/windowlistener.html">Tutorial: How to Write Window Listeners</a>
48+ *
49+ * @since 1.1
50+ */
51+public interface WindowListener extends EventListener {
52+ /**
53+ * Invoked the first time a window is made visible.
54+ */
55+ public void windowOpened(WindowEvent e);
56+
57+ /**
58+ * Invoked when the user attempts to close the window
59+ * from the window's system menu.
60+ */
61+ public void windowClosing(WindowEvent e);
62+
63+ /**
64+ * Invoked when a window has been closed as the result
65+ * of calling dispose on the window.
66+ */
67+ public void windowClosed(WindowEvent e);
68+
69+ /**
70+ * Invoked when a window is changed from a normal to a
71+ * minimized state. For many platforms, a minimized window
72+ * is displayed as the icon specified in the window's
73+ * iconImage property.
74+ * @see java.awt.Frame#setIconImage
75+ */
76+ public void windowIconified(WindowEvent e);
77+
78+ /**
79+ * Invoked when a window is changed from a minimized
80+ * to a normal state.
81+ */
82+ public void windowDeiconified(WindowEvent e);
83+
84+ /**
85+ * Invoked when the Window is set to be the active Window. Only a Frame or
86+ * a Dialog can be the active Window. The native windowing system may
87+ * denote the active Window or its children with special decorations, such
88+ * as a highlighted title bar. The active Window is always either the
89+ * focused Window, or the first Frame or Dialog that is an owner of the
90+ * focused Window.
91+ */
92+ public void windowActivated(WindowEvent e);
93+
94+ /**
95+ * Invoked when a Window is no longer the active Window. Only a Frame or a
96+ * Dialog can be the active Window. The native windowing system may denote
97+ * the active Window or its children with special decorations, such as a
98+ * highlighted title bar. The active Window is always either the focused
99+ * Window, or the first Frame or Dialog that is an owner of the focused
100+ * Window.
101+ */
102+ public void windowDeactivated(WindowEvent e);
103+}
java/pkg/java/awt/event/WindowStateListener.class+0−0

Binary file not shown.

java/pkg/java/awt/event/WindowStateListener.java+55−0
@@ -0,0 +1,55 @@
1+/*
2+ * Copyright (c) 2001, 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.event;
27+
28+import java.util.EventListener;
29+
30+/**
31+ * The listener interface for receiving window state events.
32+ * <p>
33+ * The class that is interested in processing a window state event
34+ * either implements this interface (and all the methods it contains)
35+ * or extends the abstract <code>WindowAdapter</code> class
36+ * (overriding only the methods of interest).
37+ * <p>
38+ * The listener object created from that class is then registered with
39+ * a window using the <code>Window</code>'s
40+ * <code>addWindowStateListener</code> method. When the window's
41+ * state changes by virtue of being iconified, maximized etc., the
42+ * <code>windowStateChanged</code> method in the listener object is
43+ * invoked, and the <code>WindowEvent</code> is passed to it.
44+ *
45+ * @see java.awt.event.WindowAdapter
46+ * @see java.awt.event.WindowEvent
47+ *
48+ * @since 1.4
49+ */
50+public interface WindowStateListener extends EventListener {
51+ /**
52+ * Invoked when window state is changed.
53+ */
54+ public void windowStateChanged(WindowEvent e);
55+}
java/pkg/java/awt/event/mkfile+51−0
@@ -0,0 +1,51 @@
1+<../../../../../mkconfig
2+
3+TARG=\
4+ ActionEvent.dis\
5+ ActionListener.dis\
6+ AdjustmentEvent.dis\
7+ AdjustmentListener.dis\
8+ AWTEventListener.dis\
9+ AWTEventListenerProxy.dis\
10+ ComponentAdapter.dis\
11+ ComponentEvent.dis\
12+ ComponentListener.dis\
13+ ContainerAdapter.dis\
14+ ContainerEvent.dis\
15+ ContainerListener.dis\
16+ FocusAdapter.dis\
17+ FocusEvent.dis\
18+ FocusListener.dis\
19+ HierarchyBoundsAdapter.dis\
20+ HierarchyBoundsListener.dis\
21+ HierarchyEvent.dis\
22+ HierarchyListener.dis\
23+ InputEvent.dis\
24+ InputMethodEvent.dis\
25+ InputMethodListener.dis\
26+ InvocationEvent.dis\
27+ ItemEvent.dis\
28+ ItemListener.dis\
29+ KeyAdapter.dis\
30+ KeyEvent.dis\
31+ KeyListener.dis\
32+ MouseAdapter.dis\
33+ MouseEvent.dis\
34+ MouseListener.dis\
35+ MouseMotionAdapter.dis\
36+ MouseMotionListener.dis\
37+ MouseWheelEvent.dis\
38+ MouseWheelListener.dis\
39+ NativeLibLoader.dis\
40+ PaintEvent.dis\
41+ TextEvent.dis\
42+ TextListener.dis\
43+ WindowAdapter.dis\
44+ WindowEvent.dis\
45+ WindowFocusListener.dis\
46+ WindowListener.dis\
47+ WindowStateListener.dis\
48+
49+DISBIN=$ROOT/java/dis/java/java/java/awt/event
50+
51+<$ROOT/mkfiles/mkjava
java/pkg/java/awt/event/package.html+57−0
@@ -0,0 +1,57 @@
1+<!--
2+ Copyright (c) 1998, 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+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
27+<html>
28+<body bgcolor="white">
29+
30+Provides interfaces and classes for dealing with different
31+types of events fired by AWT components. See the java.awt.AWTEvent
32+class for details on the AWT event model. Events are fired by event
33+sources. An event listener registers with an event source to receive
34+notifications about the events of a particular type. This package
35+defines events and event listeners, as well as event listener
36+adapters, which are convenience classes to make easier the process of
37+writing event listeners.
38+
39+<!--
40+<h2>Package Specification</h2>
41+
42+##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
43+<ul>
44+ <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
45+</ul>
46+
47+<h2>Related Documentation</h2>
48+
49+For overviews, tutorials, examples, guides, and tool documentation, please see:
50+<ul>
51+ <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
52+</ul>
53+-->
54+
55+@since JDK1.1
56+</body>
57+</html>