author | alexsch |
Wed, 24 Aug 2016 00:23:49 +0400 | |
changeset 40719 | 4ae72a69bd3b |
parent 37694 | c064aefc5a2f |
child 41395 | 2a6f7eb1dc23 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
37694
c064aefc5a2f
8080395: consider making sun.awt.CausedFocusEvent functionality public
ssadetsky
parents:
36511
diff
changeset
|
2 |
* Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
package java.awt; |
|
26 |
||
27 |
import java.awt.event.*; |
|
2648 | 28 |
import java.awt.geom.Path2D; |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
29 |
import java.awt.geom.Point2D; |
2 | 30 |
import java.awt.im.InputContext; |
31 |
import java.awt.image.BufferStrategy; |
|
32 |
import java.awt.peer.ComponentPeer; |
|
33 |
import java.awt.peer.WindowPeer; |
|
34 |
import java.beans.PropertyChangeListener; |
|
35 |
import java.io.IOException; |
|
36 |
import java.io.ObjectInputStream; |
|
37 |
import java.io.ObjectOutputStream; |
|
38 |
import java.io.OptionalDataException; |
|
39 |
import java.io.Serializable; |
|
40 |
import java.lang.ref.WeakReference; |
|
41 |
import java.lang.reflect.InvocationTargetException; |
|
42 |
import java.security.AccessController; |
|
43 |
import java.util.ArrayList; |
|
44 |
import java.util.Arrays; |
|
45 |
import java.util.EventListener; |
|
46 |
import java.util.Locale; |
|
47 |
import java.util.ResourceBundle; |
|
48 |
import java.util.Set; |
|
49 |
import java.util.Vector; |
|
50 |
import java.util.concurrent.atomic.AtomicBoolean; |
|
51 |
import javax.accessibility.*; |
|
2451 | 52 |
import sun.awt.AWTAccessor; |
22060
cd4f9d7dbeda
8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents:
21957
diff
changeset
|
53 |
import sun.awt.AWTPermissions; |
2 | 54 |
import sun.awt.AppContext; |
32294
58789f875b54
4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
30471
diff
changeset
|
55 |
import sun.awt.DebugSettings; |
2 | 56 |
import sun.awt.SunToolkit; |
57 |
import sun.awt.util.IdentityArrayList; |
|
58 |
import sun.java2d.pipe.Region; |
|
59 |
import sun.security.action.GetPropertyAction; |
|
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3711
diff
changeset
|
60 |
import sun.util.logging.PlatformLogger; |
2 | 61 |
|
62 |
/** |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
63 |
* A {@code Window} object is a top-level window with no borders and no |
2 | 64 |
* menubar. |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
65 |
* The default layout for a window is {@code BorderLayout}. |
2 | 66 |
* <p> |
67 |
* A window must have either a frame, dialog, or another window defined as its |
|
68 |
* owner when it's constructed. |
|
69 |
* <p> |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
70 |
* In a multi-screen environment, you can create a {@code Window} |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
71 |
* on a different screen device by constructing the {@code Window} |
2 | 72 |
* with {@link #Window(Window, GraphicsConfiguration)}. The |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
73 |
* {@code GraphicsConfiguration} object is one of the |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
74 |
* {@code GraphicsConfiguration} objects of the target screen device. |
2 | 75 |
* <p> |
76 |
* In a virtual device multi-screen environment in which the desktop |
|
77 |
* area could span multiple physical screen devices, the bounds of all |
|
78 |
* configurations are relative to the virtual device coordinate system. |
|
79 |
* The origin of the virtual-coordinate system is at the upper left-hand |
|
80 |
* corner of the primary physical screen. Depending on the location of |
|
81 |
* the primary screen in the virtual device, negative coordinates are |
|
82 |
* possible, as shown in the following figure. |
|
83 |
* <p> |
|
84 |
* <img src="doc-files/MultiScreen.gif" |
|
85 |
* alt="Diagram shows virtual device containing 4 physical screens. Primary physical screen shows coords (0,0), other screen shows (-80,-100)." |
|
20451
4cedf4e1560a
8025409: Fix javadoc comments errors and warning reported by doclint report
cl
parents:
20450
diff
changeset
|
86 |
* style="float:center; margin: 7px 10px;"> |
2 | 87 |
* <p> |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
88 |
* In such an environment, when calling {@code setLocation}, |
2 | 89 |
* you must pass a virtual coordinate to this method. Similarly, |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
90 |
* calling {@code getLocationOnScreen} on a {@code Window} returns |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
91 |
* virtual device coordinates. Call the {@code getBounds} method |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
92 |
* of a {@code GraphicsConfiguration} to find its origin in the virtual |
2 | 93 |
* coordinate system. |
94 |
* <p> |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
95 |
* The following code sets the location of a {@code Window} |
2 | 96 |
* at (10, 10) relative to the origin of the physical screen |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
97 |
* of the corresponding {@code GraphicsConfiguration}. If the |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
98 |
* bounds of the {@code GraphicsConfiguration} is not taken |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
99 |
* into account, the {@code Window} location would be set |
2 | 100 |
* at (10, 10) relative to the virtual-coordinate system and would appear |
101 |
* on the primary physical screen, which might be different from the |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
102 |
* physical screen of the specified {@code GraphicsConfiguration}. |
2 | 103 |
* |
104 |
* <pre> |
|
105 |
* Window w = new Window(Window owner, GraphicsConfiguration gc); |
|
106 |
* Rectangle bounds = gc.getBounds(); |
|
107 |
* w.setLocation(10 + bounds.x, 10 + bounds.y); |
|
108 |
* </pre> |
|
109 |
* |
|
110 |
* <p> |
|
111 |
* Note: the location and size of top-level windows (including |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
112 |
* {@code Window}s, {@code Frame}s, and {@code Dialog}s) |
2 | 113 |
* are under the control of the desktop's window management system. |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
114 |
* Calls to {@code setLocation}, {@code setSize}, and |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
115 |
* {@code setBounds} are requests (not directives) which are |
2 | 116 |
* forwarded to the window management system. Every effort will be |
117 |
* made to honor such requests. However, in some cases the window |
|
118 |
* management system may ignore such requests, or modify the requested |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
119 |
* geometry in order to place and size the {@code Window} in a way |
2 | 120 |
* that more closely matches the desktop settings. |
121 |
* <p> |
|
122 |
* Due to the asynchronous nature of native event handling, the results |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
123 |
* returned by {@code getBounds}, {@code getLocation}, |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
124 |
* {@code getLocationOnScreen}, and {@code getSize} might not |
2 | 125 |
* reflect the actual geometry of the Window on screen until the last |
126 |
* request has been processed. During the processing of subsequent |
|
127 |
* requests these values might change accordingly while the window |
|
128 |
* management system fulfills the requests. |
|
129 |
* <p> |
|
130 |
* An application may set the size and location of an invisible |
|
131 |
* {@code Window} arbitrarily, but the window management system may |
|
132 |
* subsequently change its size and/or location when the |
|
133 |
* {@code Window} is made visible. One or more {@code ComponentEvent}s |
|
134 |
* will be generated to indicate the new geometry. |
|
135 |
* <p> |
|
136 |
* Windows are capable of generating the following WindowEvents: |
|
137 |
* WindowOpened, WindowClosed, WindowGainedFocus, WindowLostFocus. |
|
138 |
* |
|
139 |
* @author Sami Shaio |
|
140 |
* @author Arthur van Hoff |
|
141 |
* @see WindowEvent |
|
142 |
* @see #addWindowListener |
|
143 |
* @see java.awt.BorderLayout |
|
24865
09b1d992ca72
8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents:
23717
diff
changeset
|
144 |
* @since 1.0 |
2 | 145 |
*/ |
146 |
public class Window extends Container implements Accessible { |
|
147 |
||
148 |
/** |
|
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
149 |
* Enumeration of available <i>window types</i>. |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
150 |
* |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
151 |
* A window type defines the generic visual appearance and behavior of a |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
152 |
* top-level window. For example, the type may affect the kind of |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
153 |
* decorations of a decorated {@code Frame} or {@code Dialog} instance. |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
154 |
* <p> |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
155 |
* Some platforms may not fully support a certain window type. Depending on |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
156 |
* the level of support, some properties of the window type may be |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
157 |
* disobeyed. |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
158 |
* |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
159 |
* @see #getType |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
160 |
* @see #setType |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
161 |
* @since 1.7 |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
162 |
*/ |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
163 |
public static enum Type { |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
164 |
/** |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
165 |
* Represents a <i>normal</i> window. |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
166 |
* |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
167 |
* This is the default type for objects of the {@code Window} class or |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
168 |
* its descendants. Use this type for regular top-level windows. |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
169 |
*/ |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
170 |
NORMAL, |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
171 |
|
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
172 |
/** |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
173 |
* Represents a <i>utility</i> window. |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
174 |
* |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
175 |
* A utility window is usually a small window such as a toolbar or a |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
176 |
* palette. The native system may render the window with smaller |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
177 |
* title-bar if the window is either a {@code Frame} or a {@code |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
178 |
* Dialog} object, and if it has its decorations enabled. |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
179 |
*/ |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
180 |
UTILITY, |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
181 |
|
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
182 |
/** |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
183 |
* Represents a <i>popup</i> window. |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
184 |
* |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
185 |
* A popup window is a temporary window such as a drop-down menu or a |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
186 |
* tooltip. On some platforms, windows of that type may be forcibly |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
187 |
* made undecorated even if they are instances of the {@code Frame} or |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
188 |
* {@code Dialog} class, and have decorations enabled. |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
189 |
*/ |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
190 |
POPUP |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
191 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
192 |
|
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
193 |
/** |
2 | 194 |
* This represents the warning message that is |
195 |
* to be displayed in a non secure window. ie : |
|
19807
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
196 |
* a window that has a security manager installed that denies |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
197 |
* {@code AWTPermission("showWindowWithoutWarningBanner")}. |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
198 |
* This message can be displayed anywhere in the window. |
2 | 199 |
* |
200 |
* @serial |
|
201 |
* @see #getWarningString |
|
202 |
*/ |
|
203 |
String warningString; |
|
204 |
||
205 |
/** |
|
206 |
* {@code icons} is the graphical way we can |
|
207 |
* represent the frames and dialogs. |
|
208 |
* {@code Window} can't display icon but it's |
|
209 |
* being inherited by owned {@code Dialog}s. |
|
210 |
* |
|
211 |
* @serial |
|
212 |
* @see #getIconImages |
|
21957 | 213 |
* @see #setIconImages |
2 | 214 |
*/ |
215 |
transient java.util.List<Image> icons; |
|
216 |
||
217 |
/** |
|
218 |
* Holds the reference to the component which last had focus in this window |
|
219 |
* before it lost focus. |
|
220 |
*/ |
|
221 |
private transient Component temporaryLostComponent; |
|
222 |
||
223 |
static boolean systemSyncLWRequests = false; |
|
224 |
boolean syncLWRequests = false; |
|
225 |
transient boolean beforeFirstShow = true; |
|
11982
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
226 |
private transient boolean disposing = false; |
20450 | 227 |
transient WindowDisposerRecord disposerRecord = null; |
2 | 228 |
|
229 |
static final int OPENED = 0x01; |
|
230 |
||
231 |
/** |
|
232 |
* An Integer value representing the Window State. |
|
233 |
* |
|
234 |
* @serial |
|
235 |
* @since 1.2 |
|
236 |
* @see #show |
|
237 |
*/ |
|
238 |
int state; |
|
239 |
||
240 |
/** |
|
241 |
* A boolean value representing Window always-on-top state |
|
242 |
* @since 1.5 |
|
243 |
* @serial |
|
244 |
* @see #setAlwaysOnTop |
|
245 |
* @see #isAlwaysOnTop |
|
246 |
*/ |
|
247 |
private boolean alwaysOnTop; |
|
248 |
||
249 |
/** |
|
250 |
* Contains all the windows that have a peer object associated, |
|
251 |
* i. e. between addNotify() and removeNotify() calls. The list |
|
252 |
* of all Window instances can be obtained from AppContext object. |
|
253 |
* |
|
254 |
* @since 1.6 |
|
255 |
*/ |
|
256 |
private static final IdentityArrayList<Window> allWindows = new IdentityArrayList<Window>(); |
|
257 |
||
258 |
/** |
|
259 |
* A vector containing all the windows this |
|
260 |
* window currently owns. |
|
261 |
* @since 1.2 |
|
262 |
* @see #getOwnedWindows |
|
263 |
*/ |
|
264 |
transient Vector<WeakReference<Window>> ownedWindowList = |
|
265 |
new Vector<WeakReference<Window>>(); |
|
266 |
||
267 |
/* |
|
268 |
* We insert a weak reference into the Vector of all Windows in AppContext |
|
269 |
* instead of 'this' so that garbage collection can still take place |
|
270 |
* correctly. |
|
271 |
*/ |
|
272 |
private transient WeakReference<Window> weakThis; |
|
273 |
||
274 |
transient boolean showWithParent; |
|
275 |
||
276 |
/** |
|
277 |
* Contains the modal dialog that blocks this window, or null |
|
278 |
* if the window is unblocked. |
|
279 |
* |
|
280 |
* @since 1.6 |
|
281 |
*/ |
|
282 |
transient Dialog modalBlocker; |
|
283 |
||
284 |
/** |
|
285 |
* @serial |
|
286 |
* |
|
287 |
* @see java.awt.Dialog.ModalExclusionType |
|
288 |
* @see #getModalExclusionType |
|
289 |
* @see #setModalExclusionType |
|
290 |
* |
|
291 |
* @since 1.6 |
|
292 |
*/ |
|
293 |
Dialog.ModalExclusionType modalExclusionType; |
|
294 |
||
295 |
transient WindowListener windowListener; |
|
296 |
transient WindowStateListener windowStateListener; |
|
297 |
transient WindowFocusListener windowFocusListener; |
|
298 |
||
299 |
transient InputContext inputContext; |
|
300 |
private transient Object inputContextLock = new Object(); |
|
301 |
||
302 |
/** |
|
303 |
* Unused. Maintained for serialization backward-compatibility. |
|
304 |
* |
|
305 |
* @serial |
|
306 |
* @since 1.2 |
|
307 |
*/ |
|
308 |
private FocusManager focusMgr; |
|
309 |
||
310 |
/** |
|
311 |
* Indicates whether this Window can become the focused Window. |
|
312 |
* |
|
313 |
* @serial |
|
314 |
* @see #getFocusableWindowState |
|
315 |
* @see #setFocusableWindowState |
|
316 |
* @since 1.4 |
|
317 |
*/ |
|
318 |
private boolean focusableWindowState = true; |
|
319 |
||
320 |
/** |
|
321 |
* Indicates whether this window should receive focus on |
|
322 |
* subsequently being shown (with a call to {@code setVisible(true)}), or |
|
323 |
* being moved to the front (with a call to {@code toFront()}). |
|
324 |
* |
|
325 |
* @serial |
|
326 |
* @see #setAutoRequestFocus |
|
327 |
* @see #isAutoRequestFocus |
|
328 |
* @since 1.7 |
|
329 |
*/ |
|
330 |
private volatile boolean autoRequestFocus = true; |
|
331 |
||
332 |
/* |
|
333 |
* Indicates that this window is being shown. This flag is set to true at |
|
334 |
* the beginning of show() and to false at the end of show(). |
|
335 |
* |
|
336 |
* @see #show() |
|
337 |
* @see Dialog#shouldBlock |
|
338 |
*/ |
|
339 |
transient boolean isInShow = false; |
|
340 |
||
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
341 |
/** |
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
342 |
* The opacity level of the window |
2451 | 343 |
* |
2648 | 344 |
* @serial |
2451 | 345 |
* @see #setOpacity(float) |
346 |
* @see #getOpacity() |
|
347 |
* @since 1.7 |
|
348 |
*/ |
|
33510
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
32865
diff
changeset
|
349 |
private volatile float opacity = 1.0f; |
2451 | 350 |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
351 |
/** |
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
352 |
* The shape assigned to this window. This field is set to {@code null} if |
2451 | 353 |
* no shape is set (rectangular window). |
354 |
* |
|
2648 | 355 |
* @serial |
2451 | 356 |
* @see #getShape() |
357 |
* @see #setShape(Shape) |
|
358 |
* @since 1.7 |
|
359 |
*/ |
|
360 |
private Shape shape = null; |
|
361 |
||
2 | 362 |
private static final String base = "win"; |
363 |
private static int nameCounter = 0; |
|
364 |
||
365 |
/* |
|
366 |
* JDK 1.1 serialVersionUID |
|
367 |
*/ |
|
368 |
private static final long serialVersionUID = 4497834738069338734L; |
|
369 |
||
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3711
diff
changeset
|
370 |
private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.Window"); |
2 | 371 |
|
372 |
private static final boolean locationByPlatformProp; |
|
373 |
||
374 |
transient boolean isTrayIconWindow = false; |
|
375 |
||
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
376 |
/** |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
377 |
* These fields are initialized in the native peer code |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
378 |
* or via AWTAccessor's WindowAccessor. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
379 |
*/ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
380 |
private transient volatile int securityWarningWidth = 0; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
381 |
private transient volatile int securityWarningHeight = 0; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
382 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
383 |
/** |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
384 |
* These fields represent the desired location for the security |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
385 |
* warning if this window is untrusted. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
386 |
* See com.sun.awt.SecurityWarning for more details. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
387 |
*/ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
388 |
private transient double securityWarningPointX = 2.0; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
389 |
private transient double securityWarningPointY = 0.0; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
390 |
private transient float securityWarningAlignmentX = RIGHT_ALIGNMENT; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
391 |
private transient float securityWarningAlignmentY = TOP_ALIGNMENT; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
392 |
|
2 | 393 |
static { |
394 |
/* ensure that the necessary native libraries are loaded */ |
|
395 |
Toolkit.loadLibraries(); |
|
396 |
if (!GraphicsEnvironment.isHeadless()) { |
|
397 |
initIDs(); |
|
398 |
} |
|
399 |
||
11813
643f5bef6ab4
7144475: fix some warnings in java.awt, javax.print.attribute.standard, and sun.beans.infos
chegar
parents:
9210
diff
changeset
|
400 |
String s = java.security.AccessController.doPrivileged( |
2 | 401 |
new GetPropertyAction("java.awt.syncLWRequests")); |
402 |
systemSyncLWRequests = (s != null && s.equals("true")); |
|
11813
643f5bef6ab4
7144475: fix some warnings in java.awt, javax.print.attribute.standard, and sun.beans.infos
chegar
parents:
9210
diff
changeset
|
403 |
s = java.security.AccessController.doPrivileged( |
2 | 404 |
new GetPropertyAction("java.awt.Window.locationByPlatform")); |
405 |
locationByPlatformProp = (s != null && s.equals("true")); |
|
406 |
} |
|
407 |
||
408 |
/** |
|
409 |
* Initialize JNI field and method IDs for fields that may be |
|
410 |
accessed from C. |
|
411 |
*/ |
|
412 |
private static native void initIDs(); |
|
413 |
||
414 |
/** |
|
415 |
* Constructs a new, initially invisible window in default size with the |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
416 |
* specified {@code GraphicsConfiguration}. |
2 | 417 |
* <p> |
19807
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
418 |
* If there is a security manager, then it is invoked to check |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
419 |
* {@code AWTPermission("showWindowWithoutWarningBanner")} |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
420 |
* to determine whether or not the window must be displayed with |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
421 |
* a warning banner. |
2 | 422 |
* |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
423 |
* @param gc the {@code GraphicsConfiguration} of the target screen |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
424 |
* device. If {@code gc} is {@code null}, the system default |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
425 |
* {@code GraphicsConfiguration} is assumed |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
426 |
* @exception IllegalArgumentException if {@code gc} |
2 | 427 |
* is not from a screen device |
428 |
* @exception HeadlessException when |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
429 |
* {@code GraphicsEnvironment.isHeadless()} returns {@code true} |
2 | 430 |
* |
431 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
432 |
*/ |
|
433 |
Window(GraphicsConfiguration gc) { |
|
434 |
init(gc); |
|
435 |
} |
|
436 |
||
437 |
transient Object anchor = new Object(); |
|
438 |
static class WindowDisposerRecord implements sun.java2d.DisposerRecord { |
|
20450 | 439 |
WeakReference<Window> owner; |
15318
607db339afcc
8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents:
12661
diff
changeset
|
440 |
final WeakReference<Window> weakThis; |
106
e8dca729bb5b
6616095: AWT's WindowDisposerRecord keeps AppContext alive too long
son
parents:
2
diff
changeset
|
441 |
final WeakReference<AppContext> context; |
20450 | 442 |
|
2 | 443 |
WindowDisposerRecord(AppContext context, Window victim) { |
444 |
weakThis = victim.weakThis; |
|
106
e8dca729bb5b
6616095: AWT's WindowDisposerRecord keeps AppContext alive too long
son
parents:
2
diff
changeset
|
445 |
this.context = new WeakReference<AppContext>(context); |
2 | 446 |
} |
20450 | 447 |
|
448 |
public void updateOwner() { |
|
449 |
Window victim = weakThis.get(); |
|
450 |
owner = (victim == null) |
|
451 |
? null |
|
452 |
: new WeakReference<Window>(victim.getOwner()); |
|
453 |
} |
|
454 |
||
2 | 455 |
public void dispose() { |
20450 | 456 |
if (owner != null) { |
457 |
Window parent = owner.get(); |
|
458 |
if (parent != null) { |
|
459 |
parent.removeOwnedWindow(weakThis); |
|
460 |
} |
|
2 | 461 |
} |
106
e8dca729bb5b
6616095: AWT's WindowDisposerRecord keeps AppContext alive too long
son
parents:
2
diff
changeset
|
462 |
AppContext ac = context.get(); |
e8dca729bb5b
6616095: AWT's WindowDisposerRecord keeps AppContext alive too long
son
parents:
2
diff
changeset
|
463 |
if (null != ac) { |
e8dca729bb5b
6616095: AWT's WindowDisposerRecord keeps AppContext alive too long
son
parents:
2
diff
changeset
|
464 |
Window.removeFromWindowList(ac, weakThis); |
e8dca729bb5b
6616095: AWT's WindowDisposerRecord keeps AppContext alive too long
son
parents:
2
diff
changeset
|
465 |
} |
2 | 466 |
} |
467 |
} |
|
468 |
||
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
469 |
private GraphicsConfiguration initGC(GraphicsConfiguration gc) { |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
470 |
GraphicsEnvironment.checkHeadless(); |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
471 |
|
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
472 |
if (gc == null) { |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
473 |
gc = GraphicsEnvironment.getLocalGraphicsEnvironment(). |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
474 |
getDefaultScreenDevice().getDefaultConfiguration(); |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
475 |
} |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
476 |
setGraphicsConfiguration(gc); |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
477 |
|
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
478 |
return gc; |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
479 |
} |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
480 |
|
2 | 481 |
private void init(GraphicsConfiguration gc) { |
482 |
GraphicsEnvironment.checkHeadless(); |
|
483 |
||
484 |
syncLWRequests = systemSyncLWRequests; |
|
485 |
||
486 |
weakThis = new WeakReference<Window>(this); |
|
487 |
addToWindowList(); |
|
488 |
||
489 |
setWarningString(); |
|
490 |
this.cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); |
|
491 |
this.visible = false; |
|
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
492 |
|
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
493 |
gc = initGC(gc); |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
494 |
|
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
495 |
if (gc.getDevice().getType() != |
2 | 496 |
GraphicsDevice.TYPE_RASTER_SCREEN) { |
497 |
throw new IllegalArgumentException("not a screen device"); |
|
498 |
} |
|
499 |
setLayout(new BorderLayout()); |
|
500 |
||
501 |
/* offset the initial location with the original of the screen */ |
|
502 |
/* and any insets */ |
|
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
503 |
Rectangle screenBounds = gc.getBounds(); |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
504 |
Insets screenInsets = getToolkit().getScreenInsets(gc); |
2 | 505 |
int x = getX() + screenBounds.x + screenInsets.left; |
506 |
int y = getY() + screenBounds.y + screenInsets.top; |
|
507 |
if (x != this.x || y != this.y) { |
|
508 |
setLocation(x, y); |
|
509 |
/* reset after setLocation */ |
|
510 |
setLocationByPlatform(locationByPlatformProp); |
|
511 |
} |
|
512 |
||
513 |
modalExclusionType = Dialog.ModalExclusionType.NO_EXCLUDE; |
|
20450 | 514 |
disposerRecord = new WindowDisposerRecord(appContext, this); |
515 |
sun.java2d.Disposer.addRecord(anchor, disposerRecord); |
|
8136
d81295a8ece1
6741526: KeyboardFocusManager.setDefaultFocusTraversalPolicy(FocusTraversalPolicy) affects created components
dav
parents:
7668
diff
changeset
|
516 |
|
12661
6cf8b7116579
7125044: [macosx] Test failure because Component.transferFocus() works differently in applet and application.
ant
parents:
12651
diff
changeset
|
517 |
SunToolkit.checkAndSetPolicy(this); |
2 | 518 |
} |
519 |
||
520 |
/** |
|
521 |
* Constructs a new, initially invisible window in the default size. |
|
19807
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
522 |
* <p> |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
523 |
* If there is a security manager set, it is invoked to check |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
524 |
* {@code AWTPermission("showWindowWithoutWarningBanner")}. |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
525 |
* If that check fails with a {@code SecurityException} then a warning |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
526 |
* banner is created. |
2 | 527 |
* |
528 |
* @exception HeadlessException when |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
529 |
* {@code GraphicsEnvironment.isHeadless()} returns {@code true} |
2 | 530 |
* |
531 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
532 |
*/ |
|
533 |
Window() throws HeadlessException { |
|
534 |
GraphicsEnvironment.checkHeadless(); |
|
535 |
init((GraphicsConfiguration)null); |
|
536 |
} |
|
537 |
||
538 |
/** |
|
539 |
* Constructs a new, initially invisible window with the specified |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
540 |
* {@code Frame} as its owner. The window will not be focusable |
2 | 541 |
* unless its owner is showing on the screen. |
542 |
* <p> |
|
19807
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
543 |
* If there is a security manager set, it is invoked to check |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
544 |
* {@code AWTPermission("showWindowWithoutWarningBanner")}. |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
545 |
* If that check fails with a {@code SecurityException} then a warning |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
546 |
* banner is created. |
2 | 547 |
* |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
548 |
* @param owner the {@code Frame} to act as owner or {@code null} |
2 | 549 |
* if this window has no owner |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
550 |
* @exception IllegalArgumentException if the {@code owner}'s |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
551 |
* {@code GraphicsConfiguration} is not from a screen device |
2 | 552 |
* @exception HeadlessException when |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
553 |
* {@code GraphicsEnvironment.isHeadless} returns {@code true} |
2 | 554 |
* |
555 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
556 |
* @see #isShowing |
|
557 |
*/ |
|
558 |
public Window(Frame owner) { |
|
559 |
this(owner == null ? (GraphicsConfiguration)null : |
|
560 |
owner.getGraphicsConfiguration()); |
|
561 |
ownedInit(owner); |
|
562 |
} |
|
563 |
||
564 |
/** |
|
565 |
* Constructs a new, initially invisible window with the specified |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
566 |
* {@code Window} as its owner. This window will not be focusable |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
567 |
* unless its nearest owning {@code Frame} or {@code Dialog} |
2 | 568 |
* is showing on the screen. |
569 |
* <p> |
|
19807
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
570 |
* If there is a security manager set, it is invoked to check |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
571 |
* {@code AWTPermission("showWindowWithoutWarningBanner")}. |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
572 |
* If that check fails with a {@code SecurityException} then a |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
573 |
* warning banner is created. |
2 | 574 |
* |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
575 |
* @param owner the {@code Window} to act as owner or |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
576 |
* {@code null} if this window has no owner |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
577 |
* @exception IllegalArgumentException if the {@code owner}'s |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
578 |
* {@code GraphicsConfiguration} is not from a screen device |
2 | 579 |
* @exception HeadlessException when |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
580 |
* {@code GraphicsEnvironment.isHeadless()} returns |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
581 |
* {@code true} |
2 | 582 |
* |
583 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
584 |
* @see #isShowing |
|
585 |
* |
|
586 |
* @since 1.2 |
|
587 |
*/ |
|
588 |
public Window(Window owner) { |
|
589 |
this(owner == null ? (GraphicsConfiguration)null : |
|
590 |
owner.getGraphicsConfiguration()); |
|
591 |
ownedInit(owner); |
|
592 |
} |
|
593 |
||
594 |
/** |
|
595 |
* Constructs a new, initially invisible window with the specified owner |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
596 |
* {@code Window} and a {@code GraphicsConfiguration} |
2 | 597 |
* of a screen device. The Window will not be focusable unless |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
598 |
* its nearest owning {@code Frame} or {@code Dialog} |
2 | 599 |
* is showing on the screen. |
600 |
* <p> |
|
19807
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
601 |
* If there is a security manager set, it is invoked to check |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
602 |
* {@code AWTPermission("showWindowWithoutWarningBanner")}. If that |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
603 |
* check fails with a {@code SecurityException} then a warning banner |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
604 |
* is created. |
2 | 605 |
* |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
606 |
* @param owner the window to act as owner or {@code null} |
2 | 607 |
* if this window has no owner |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
608 |
* @param gc the {@code GraphicsConfiguration} of the target |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
609 |
* screen device; if {@code gc} is {@code null}, |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
610 |
* the system default {@code GraphicsConfiguration} is assumed |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
611 |
* @exception IllegalArgumentException if {@code gc} |
2 | 612 |
* is not from a screen device |
613 |
* @exception HeadlessException when |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
614 |
* {@code GraphicsEnvironment.isHeadless()} returns |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
615 |
* {@code true} |
2 | 616 |
* |
617 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
618 |
* @see GraphicsConfiguration#getBounds |
|
619 |
* @see #isShowing |
|
620 |
* @since 1.3 |
|
621 |
*/ |
|
622 |
public Window(Window owner, GraphicsConfiguration gc) { |
|
623 |
this(gc); |
|
624 |
ownedInit(owner); |
|
625 |
} |
|
626 |
||
627 |
private void ownedInit(Window owner) { |
|
628 |
this.parent = owner; |
|
629 |
if (owner != null) { |
|
630 |
owner.addOwnedWindow(weakThis); |
|
20467
c516e99769d7
7081594: Windows owned by an always-on-top window DO NOT automatically become always-on-top
alexsch
parents:
20465
diff
changeset
|
631 |
if (owner.isAlwaysOnTop()) { |
c516e99769d7
7081594: Windows owned by an always-on-top window DO NOT automatically become always-on-top
alexsch
parents:
20465
diff
changeset
|
632 |
try { |
c516e99769d7
7081594: Windows owned by an always-on-top window DO NOT automatically become always-on-top
alexsch
parents:
20465
diff
changeset
|
633 |
setAlwaysOnTop(true); |
c516e99769d7
7081594: Windows owned by an always-on-top window DO NOT automatically become always-on-top
alexsch
parents:
20465
diff
changeset
|
634 |
} catch (SecurityException ignore) { |
c516e99769d7
7081594: Windows owned by an always-on-top window DO NOT automatically become always-on-top
alexsch
parents:
20465
diff
changeset
|
635 |
} |
c516e99769d7
7081594: Windows owned by an always-on-top window DO NOT automatically become always-on-top
alexsch
parents:
20465
diff
changeset
|
636 |
} |
2 | 637 |
} |
1972 | 638 |
|
639 |
// WindowDisposerRecord requires a proper value of parent field. |
|
20450 | 640 |
disposerRecord.updateOwner(); |
2 | 641 |
} |
642 |
||
643 |
/** |
|
644 |
* Construct a name for this component. Called by getName() when the |
|
645 |
* name is null. |
|
646 |
*/ |
|
647 |
String constructComponentName() { |
|
648 |
synchronized (Window.class) { |
|
649 |
return base + nameCounter++; |
|
650 |
} |
|
651 |
} |
|
652 |
||
653 |
/** |
|
654 |
* Returns the sequence of images to be displayed as the icon for this window. |
|
655 |
* <p> |
|
656 |
* This method returns a copy of the internally stored list, so all operations |
|
657 |
* on the returned object will not affect the window's behavior. |
|
658 |
* |
|
659 |
* @return the copy of icon images' list for this window, or |
|
660 |
* empty list if this window doesn't have icon images. |
|
661 |
* @see #setIconImages |
|
662 |
* @see #setIconImage(Image) |
|
663 |
* @since 1.6 |
|
664 |
*/ |
|
665 |
public java.util.List<Image> getIconImages() { |
|
666 |
java.util.List<Image> icons = this.icons; |
|
667 |
if (icons == null || icons.size() == 0) { |
|
668 |
return new ArrayList<Image>(); |
|
669 |
} |
|
670 |
return new ArrayList<Image>(icons); |
|
671 |
} |
|
672 |
||
673 |
/** |
|
674 |
* Sets the sequence of images to be displayed as the icon |
|
675 |
* for this window. Subsequent calls to {@code getIconImages} will |
|
676 |
* always return a copy of the {@code icons} list. |
|
677 |
* <p> |
|
678 |
* Depending on the platform capabilities one or several images |
|
679 |
* of different dimensions will be used as the window's icon. |
|
680 |
* <p> |
|
681 |
* The {@code icons} list is scanned for the images of most |
|
682 |
* appropriate dimensions from the beginning. If the list contains |
|
683 |
* several images of the same size, the first will be used. |
|
684 |
* <p> |
|
26749 | 685 |
* Ownerless windows with no icon specified use platform-default icon. |
2 | 686 |
* The icon of an owned window may be inherited from the owner |
687 |
* unless explicitly overridden. |
|
688 |
* Setting the icon to {@code null} or empty list restores |
|
689 |
* the default behavior. |
|
690 |
* <p> |
|
691 |
* Note : Native windowing systems may use different images of differing |
|
692 |
* dimensions to represent a window, depending on the context (e.g. |
|
693 |
* window decoration, window list, taskbar, etc.). They could also use |
|
694 |
* just a single image for all contexts or no image at all. |
|
695 |
* |
|
696 |
* @param icons the list of icon images to be displayed. |
|
697 |
* @see #getIconImages() |
|
698 |
* @see #setIconImage(Image) |
|
699 |
* @since 1.6 |
|
700 |
*/ |
|
701 |
public synchronized void setIconImages(java.util.List<? extends Image> icons) { |
|
702 |
this.icons = (icons == null) ? new ArrayList<Image>() : |
|
703 |
new ArrayList<Image>(icons); |
|
704 |
WindowPeer peer = (WindowPeer)this.peer; |
|
705 |
if (peer != null) { |
|
706 |
peer.updateIconImages(); |
|
707 |
} |
|
708 |
// Always send a property change event |
|
709 |
firePropertyChange("iconImage", null, null); |
|
710 |
} |
|
711 |
||
712 |
/** |
|
713 |
* Sets the image to be displayed as the icon for this window. |
|
714 |
* <p> |
|
715 |
* This method can be used instead of {@link #setIconImages setIconImages()} |
|
716 |
* to specify a single image as a window's icon. |
|
717 |
* <p> |
|
718 |
* The following statement: |
|
719 |
* <pre> |
|
720 |
* setIconImage(image); |
|
721 |
* </pre> |
|
722 |
* is equivalent to: |
|
723 |
* <pre> |
|
724 |
* ArrayList<Image> imageList = new ArrayList<Image>(); |
|
725 |
* imageList.add(image); |
|
726 |
* setIconImages(imageList); |
|
727 |
* </pre> |
|
728 |
* <p> |
|
729 |
* Note : Native windowing systems may use different images of differing |
|
730 |
* dimensions to represent a window, depending on the context (e.g. |
|
731 |
* window decoration, window list, taskbar, etc.). They could also use |
|
732 |
* just a single image for all contexts or no image at all. |
|
733 |
* |
|
734 |
* @param image the icon image to be displayed. |
|
735 |
* @see #setIconImages |
|
736 |
* @see #getIconImages() |
|
737 |
* @since 1.6 |
|
738 |
*/ |
|
739 |
public void setIconImage(Image image) { |
|
740 |
ArrayList<Image> imageList = new ArrayList<Image>(); |
|
741 |
if (image != null) { |
|
742 |
imageList.add(image); |
|
743 |
} |
|
744 |
setIconImages(imageList); |
|
745 |
} |
|
746 |
||
747 |
/** |
|
748 |
* Makes this Window displayable by creating the connection to its |
|
749 |
* native screen resource. |
|
750 |
* This method is called internally by the toolkit and should |
|
751 |
* not be called directly by programs. |
|
752 |
* @see Component#isDisplayable |
|
753 |
* @see Container#removeNotify |
|
24865
09b1d992ca72
8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents:
23717
diff
changeset
|
754 |
* @since 1.0 |
2 | 755 |
*/ |
756 |
public void addNotify() { |
|
757 |
synchronized (getTreeLock()) { |
|
758 |
Container parent = this.parent; |
|
30469 | 759 |
if (parent != null && parent.peer == null) { |
2 | 760 |
parent.addNotify(); |
761 |
} |
|
762 |
if (peer == null) { |
|
30471
c1568a2416a8
8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents:
30469
diff
changeset
|
763 |
peer = getComponentFactory().createWindow(this); |
2455
e2d60882b891
6769607: PIT : Modal frame hangs for a while for few seconds in 6u12 b01 pit build
dcherepanov
parents:
2451
diff
changeset
|
764 |
} |
e2d60882b891
6769607: PIT : Modal frame hangs for a while for few seconds in 6u12 b01 pit build
dcherepanov
parents:
2451
diff
changeset
|
765 |
synchronized (allWindows) { |
e2d60882b891
6769607: PIT : Modal frame hangs for a while for few seconds in 6u12 b01 pit build
dcherepanov
parents:
2451
diff
changeset
|
766 |
allWindows.add(this); |
2 | 767 |
} |
768 |
super.addNotify(); |
|
769 |
} |
|
770 |
} |
|
771 |
||
772 |
/** |
|
773 |
* {@inheritDoc} |
|
774 |
*/ |
|
775 |
public void removeNotify() { |
|
776 |
synchronized (getTreeLock()) { |
|
777 |
synchronized (allWindows) { |
|
778 |
allWindows.remove(this); |
|
779 |
} |
|
780 |
super.removeNotify(); |
|
781 |
} |
|
782 |
} |
|
783 |
||
784 |
/** |
|
785 |
* Causes this Window to be sized to fit the preferred size |
|
786 |
* and layouts of its subcomponents. The resulting width and |
|
787 |
* height of the window are automatically enlarged if either |
|
788 |
* of dimensions is less than the minimum size as specified |
|
789 |
* by the previous call to the {@code setMinimumSize} method. |
|
790 |
* <p> |
|
791 |
* If the window and/or its owner are not displayable yet, |
|
792 |
* both of them are made displayable before calculating |
|
793 |
* the preferred size. The Window is validated after its |
|
794 |
* size is being calculated. |
|
795 |
* |
|
796 |
* @see Component#isDisplayable |
|
797 |
* @see #setMinimumSize |
|
798 |
*/ |
|
28231
b608ffcaed74
8066621: Suppress deprecation warnings in java.desktop module
darcy
parents:
27766
diff
changeset
|
799 |
@SuppressWarnings("deprecation") |
2 | 800 |
public void pack() { |
801 |
Container parent = this.parent; |
|
30469 | 802 |
if (parent != null && parent.peer == null) { |
2 | 803 |
parent.addNotify(); |
804 |
} |
|
805 |
if (peer == null) { |
|
806 |
addNotify(); |
|
807 |
} |
|
808 |
Dimension newSize = getPreferredSize(); |
|
809 |
if (peer != null) { |
|
810 |
setClientSize(newSize.width, newSize.height); |
|
811 |
} |
|
812 |
||
813 |
if(beforeFirstShow) { |
|
814 |
isPacked = true; |
|
815 |
} |
|
816 |
||
4261 | 817 |
validateUnconditionally(); |
2 | 818 |
} |
819 |
||
820 |
/** |
|
821 |
* Sets the minimum size of this window to a constant |
|
822 |
* value. Subsequent calls to {@code getMinimumSize} |
|
823 |
* will always return this value. If current window's |
|
824 |
* size is less than {@code minimumSize} the size of the |
|
825 |
* window is automatically enlarged to honor the minimum size. |
|
826 |
* <p> |
|
827 |
* If the {@code setSize} or {@code setBounds} methods |
|
828 |
* are called afterwards with a width or height less than |
|
829 |
* that was specified by the {@code setMinimumSize} method |
|
830 |
* the window is automatically enlarged to meet |
|
831 |
* the {@code minimumSize} value. The {@code minimumSize} |
|
832 |
* value also affects the behaviour of the {@code pack} method. |
|
833 |
* <p> |
|
834 |
* The default behavior is restored by setting the minimum size |
|
835 |
* parameter to the {@code null} value. |
|
836 |
* <p> |
|
837 |
* Resizing operation may be restricted if the user tries |
|
838 |
* to resize window below the {@code minimumSize} value. |
|
839 |
* This behaviour is platform-dependent. |
|
840 |
* |
|
841 |
* @param minimumSize the new minimum size of this window |
|
842 |
* @see Component#setMinimumSize |
|
843 |
* @see #getMinimumSize |
|
844 |
* @see #isMinimumSizeSet |
|
845 |
* @see #setSize(Dimension) |
|
846 |
* @see #pack |
|
847 |
* @since 1.6 |
|
848 |
*/ |
|
849 |
public void setMinimumSize(Dimension minimumSize) { |
|
850 |
synchronized (getTreeLock()) { |
|
851 |
super.setMinimumSize(minimumSize); |
|
852 |
Dimension size = getSize(); |
|
853 |
if (isMinimumSizeSet()) { |
|
854 |
if (size.width < minimumSize.width || size.height < minimumSize.height) { |
|
855 |
int nw = Math.max(width, minimumSize.width); |
|
856 |
int nh = Math.max(height, minimumSize.height); |
|
857 |
setSize(nw, nh); |
|
858 |
} |
|
859 |
} |
|
860 |
if (peer != null) { |
|
861 |
((WindowPeer)peer).updateMinimumSize(); |
|
862 |
} |
|
863 |
} |
|
864 |
} |
|
865 |
||
866 |
/** |
|
867 |
* {@inheritDoc} |
|
868 |
* <p> |
|
869 |
* The {@code d.width} and {@code d.height} values |
|
870 |
* are automatically enlarged if either is less than |
|
871 |
* the minimum size as specified by previous call to |
|
872 |
* {@code setMinimumSize}. |
|
9200
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
873 |
* <p> |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
874 |
* The method changes the geometry-related data. Therefore, |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
875 |
* the native windowing system may ignore such requests, or it may modify |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
876 |
* the requested data, so that the {@code Window} object is placed and sized |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
877 |
* in a way that corresponds closely to the desktop settings. |
2 | 878 |
* |
879 |
* @see #getSize |
|
880 |
* @see #setBounds |
|
881 |
* @see #setMinimumSize |
|
882 |
* @since 1.6 |
|
883 |
*/ |
|
884 |
public void setSize(Dimension d) { |
|
885 |
super.setSize(d); |
|
886 |
} |
|
887 |
||
888 |
/** |
|
889 |
* {@inheritDoc} |
|
890 |
* <p> |
|
891 |
* The {@code width} and {@code height} values |
|
892 |
* are automatically enlarged if either is less than |
|
893 |
* the minimum size as specified by previous call to |
|
894 |
* {@code setMinimumSize}. |
|
9200
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
895 |
* <p> |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
896 |
* The method changes the geometry-related data. Therefore, |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
897 |
* the native windowing system may ignore such requests, or it may modify |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
898 |
* the requested data, so that the {@code Window} object is placed and sized |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
899 |
* in a way that corresponds closely to the desktop settings. |
2 | 900 |
* |
901 |
* @see #getSize |
|
902 |
* @see #setBounds |
|
903 |
* @see #setMinimumSize |
|
904 |
* @since 1.6 |
|
905 |
*/ |
|
906 |
public void setSize(int width, int height) { |
|
907 |
super.setSize(width, height); |
|
908 |
} |
|
909 |
||
910 |
/** |
|
9200
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
911 |
* {@inheritDoc} |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
912 |
* <p> |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
913 |
* The method changes the geometry-related data. Therefore, |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
914 |
* the native windowing system may ignore such requests, or it may modify |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
915 |
* the requested data, so that the {@code Window} object is placed and sized |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
916 |
* in a way that corresponds closely to the desktop settings. |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
917 |
*/ |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
918 |
@Override |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
919 |
public void setLocation(int x, int y) { |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
920 |
super.setLocation(x, y); |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
921 |
} |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
922 |
|
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
923 |
/** |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
924 |
* {@inheritDoc} |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
925 |
* <p> |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
926 |
* The method changes the geometry-related data. Therefore, |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
927 |
* the native windowing system may ignore such requests, or it may modify |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
928 |
* the requested data, so that the {@code Window} object is placed and sized |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
929 |
* in a way that corresponds closely to the desktop settings. |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
930 |
*/ |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
931 |
@Override |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
932 |
public void setLocation(Point p) { |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
933 |
super.setLocation(p); |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
934 |
} |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
935 |
|
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
936 |
/** |
2 | 937 |
* @deprecated As of JDK version 1.1, |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
938 |
* replaced by {@code setBounds(int, int, int, int)}. |
2 | 939 |
*/ |
940 |
@Deprecated |
|
941 |
public void reshape(int x, int y, int width, int height) { |
|
942 |
if (isMinimumSizeSet()) { |
|
943 |
Dimension minSize = getMinimumSize(); |
|
944 |
if (width < minSize.width) { |
|
945 |
width = minSize.width; |
|
946 |
} |
|
947 |
if (height < minSize.height) { |
|
948 |
height = minSize.height; |
|
949 |
} |
|
950 |
} |
|
951 |
super.reshape(x, y, width, height); |
|
952 |
} |
|
953 |
||
954 |
void setClientSize(int w, int h) { |
|
955 |
synchronized (getTreeLock()) { |
|
956 |
setBoundsOp(ComponentPeer.SET_CLIENT_SIZE); |
|
957 |
setBounds(x, y, w, h); |
|
958 |
} |
|
959 |
} |
|
960 |
||
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
32294
diff
changeset
|
961 |
private static final AtomicBoolean |
2 | 962 |
beforeFirstWindowShown = new AtomicBoolean(true); |
963 |
||
127
dca034368b70
6304277: PIT: Adding a TrayIcon closes a SplashScreen on Solaris but not on Win32
anthony
parents:
106
diff
changeset
|
964 |
final void closeSplashScreen() { |
dca034368b70
6304277: PIT: Adding a TrayIcon closes a SplashScreen on Solaris but not on Win32
anthony
parents:
106
diff
changeset
|
965 |
if (isTrayIconWindow) { |
dca034368b70
6304277: PIT: Adding a TrayIcon closes a SplashScreen on Solaris but not on Win32
anthony
parents:
106
diff
changeset
|
966 |
return; |
dca034368b70
6304277: PIT: Adding a TrayIcon closes a SplashScreen on Solaris but not on Win32
anthony
parents:
106
diff
changeset
|
967 |
} |
2 | 968 |
if (beforeFirstWindowShown.getAndSet(false)) { |
6823
cff6c85026c4
6990352: SplashScreen.getSplashScreen() does not return null for implicitly closed splash screen
anthony
parents:
5506
diff
changeset
|
969 |
// We don't use SplashScreen.getSplashScreen() to avoid instantiating |
cff6c85026c4
6990352: SplashScreen.getSplashScreen() does not return null for implicitly closed splash screen
anthony
parents:
5506
diff
changeset
|
970 |
// the object if it hasn't been requested by user code explicitly |
2 | 971 |
SunToolkit.closeSplashScreen(); |
6823
cff6c85026c4
6990352: SplashScreen.getSplashScreen() does not return null for implicitly closed splash screen
anthony
parents:
5506
diff
changeset
|
972 |
SplashScreen.markClosed(); |
2 | 973 |
} |
974 |
} |
|
975 |
||
976 |
/** |
|
977 |
* Shows or hides this {@code Window} depending on the value of parameter |
|
978 |
* {@code b}. |
|
979 |
* <p> |
|
980 |
* If the method shows the window then the window is also made |
|
981 |
* focused under the following conditions: |
|
982 |
* <ul> |
|
983 |
* <li> The {@code Window} meets the requirements outlined in the |
|
984 |
* {@link #isFocusableWindow} method. |
|
985 |
* <li> The {@code Window}'s {@code autoRequestFocus} property is of the {@code true} value. |
|
986 |
* <li> Native windowing system allows the {@code Window} to get focused. |
|
987 |
* </ul> |
|
988 |
* There is an exception for the second condition (the value of the |
|
989 |
* {@code autoRequestFocus} property). The property is not taken into account if the |
|
990 |
* window is a modal dialog, which blocks the currently focused window. |
|
991 |
* <p> |
|
992 |
* Developers must never assume that the window is the focused or active window |
|
993 |
* until it receives a WINDOW_GAINED_FOCUS or WINDOW_ACTIVATED event. |
|
994 |
* @param b if {@code true}, makes the {@code Window} visible, |
|
995 |
* otherwise hides the {@code Window}. |
|
996 |
* If the {@code Window} and/or its owner |
|
997 |
* are not yet displayable, both are made displayable. The |
|
998 |
* {@code Window} will be validated prior to being made visible. |
|
999 |
* If the {@code Window} is already visible, this will bring the |
|
1000 |
* {@code Window} to the front.<p> |
|
1001 |
* If {@code false}, hides this {@code Window}, its subcomponents, and all |
|
1002 |
* of its owned children. |
|
1003 |
* The {@code Window} and its subcomponents can be made visible again |
|
1004 |
* with a call to {@code #setVisible(true)}. |
|
1005 |
* @see java.awt.Component#isDisplayable |
|
1006 |
* @see java.awt.Component#setVisible |
|
1007 |
* @see java.awt.Window#toFront |
|
1008 |
* @see java.awt.Window#dispose |
|
1009 |
* @see java.awt.Window#setAutoRequestFocus |
|
1010 |
* @see java.awt.Window#isFocusableWindow |
|
1011 |
*/ |
|
1012 |
public void setVisible(boolean b) { |
|
1013 |
super.setVisible(b); |
|
1014 |
} |
|
1015 |
||
1016 |
/** |
|
1017 |
* Makes the Window visible. If the Window and/or its owner |
|
1018 |
* are not yet displayable, both are made displayable. The |
|
1019 |
* Window will be validated prior to being made visible. |
|
1020 |
* If the Window is already visible, this will bring the Window |
|
1021 |
* to the front. |
|
1022 |
* @see Component#isDisplayable |
|
1023 |
* @see #toFront |
|
1024 |
* @deprecated As of JDK version 1.5, replaced by |
|
1025 |
* {@link #setVisible(boolean)}. |
|
1026 |
*/ |
|
1027 |
@Deprecated |
|
1028 |
public void show() { |
|
1029 |
if (peer == null) { |
|
1030 |
addNotify(); |
|
1031 |
} |
|
4261 | 1032 |
validateUnconditionally(); |
2 | 1033 |
|
1034 |
isInShow = true; |
|
1035 |
if (visible) { |
|
1036 |
toFront(); |
|
1037 |
} else { |
|
1038 |
beforeFirstShow = false; |
|
1039 |
closeSplashScreen(); |
|
1040 |
Dialog.checkShouldBeBlocked(this); |
|
1041 |
super.show(); |
|
33510
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
32865
diff
changeset
|
1042 |
locationByPlatform = false; |
2 | 1043 |
for (int i = 0; i < ownedWindowList.size(); i++) { |
1044 |
Window child = ownedWindowList.elementAt(i).get(); |
|
1045 |
if ((child != null) && child.showWithParent) { |
|
1046 |
child.show(); |
|
1047 |
child.showWithParent = false; |
|
1048 |
} // endif |
|
1049 |
} // endfor |
|
1050 |
if (!isModalBlocked()) { |
|
1051 |
updateChildrenBlocking(); |
|
1052 |
} else { |
|
1053 |
// fix for 6532736: after this window is shown, its blocker |
|
1054 |
// should be raised to front |
|
1055 |
modalBlocker.toFront_NoClientCode(); |
|
1056 |
} |
|
1057 |
if (this instanceof Frame || this instanceof Dialog) { |
|
1058 |
updateChildFocusableWindowState(this); |
|
1059 |
} |
|
1060 |
} |
|
1061 |
isInShow = false; |
|
1062 |
||
1063 |
// If first time shown, generate WindowOpened event |
|
1064 |
if ((state & OPENED) == 0) { |
|
1065 |
postWindowEvent(WindowEvent.WINDOW_OPENED); |
|
1066 |
state |= OPENED; |
|
1067 |
} |
|
1068 |
} |
|
1069 |
||
1070 |
static void updateChildFocusableWindowState(Window w) { |
|
30469 | 1071 |
if (w.peer != null && w.isShowing()) { |
1072 |
((WindowPeer)w.peer).updateFocusableWindowState(); |
|
2 | 1073 |
} |
1074 |
for (int i = 0; i < w.ownedWindowList.size(); i++) { |
|
1075 |
Window child = w.ownedWindowList.elementAt(i).get(); |
|
1076 |
if (child != null) { |
|
1077 |
updateChildFocusableWindowState(child); |
|
1078 |
} |
|
1079 |
} |
|
1080 |
} |
|
1081 |
||
1082 |
synchronized void postWindowEvent(int id) { |
|
1083 |
if (windowListener != null |
|
1084 |
|| (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0 |
|
1085 |
|| Toolkit.enabledOnToolkit(AWTEvent.WINDOW_EVENT_MASK)) { |
|
1086 |
WindowEvent e = new WindowEvent(this, id); |
|
1087 |
Toolkit.getEventQueue().postEvent(e); |
|
1088 |
} |
|
1089 |
} |
|
1090 |
||
1091 |
/** |
|
1092 |
* Hide this Window, its subcomponents, and all of its owned children. |
|
1093 |
* The Window and its subcomponents can be made visible again |
|
1094 |
* with a call to {@code show}. |
|
1095 |
* @see #show |
|
1096 |
* @see #dispose |
|
1097 |
* @deprecated As of JDK version 1.5, replaced by |
|
1098 |
* {@link #setVisible(boolean)}. |
|
1099 |
*/ |
|
1100 |
@Deprecated |
|
1101 |
public void hide() { |
|
1102 |
synchronized(ownedWindowList) { |
|
1103 |
for (int i = 0; i < ownedWindowList.size(); i++) { |
|
1104 |
Window child = ownedWindowList.elementAt(i).get(); |
|
1105 |
if ((child != null) && child.visible) { |
|
1106 |
child.hide(); |
|
1107 |
child.showWithParent = true; |
|
1108 |
} |
|
1109 |
} |
|
1110 |
} |
|
1111 |
if (isModalBlocked()) { |
|
1112 |
modalBlocker.unblockWindow(this); |
|
1113 |
} |
|
1114 |
super.hide(); |
|
33510
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
32865
diff
changeset
|
1115 |
locationByPlatform = false; |
2 | 1116 |
} |
1117 |
||
1118 |
final void clearMostRecentFocusOwnerOnHide() { |
|
1119 |
/* do nothing */ |
|
1120 |
} |
|
1121 |
||
1122 |
/** |
|
1123 |
* Releases all of the native screen resources used by this |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1124 |
* {@code Window}, its subcomponents, and all of its owned |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1125 |
* children. That is, the resources for these {@code Component}s |
2 | 1126 |
* will be destroyed, any memory they consume will be returned to the |
1127 |
* OS, and they will be marked as undisplayable. |
|
1128 |
* <p> |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1129 |
* The {@code Window} and its subcomponents can be made displayable |
2 | 1130 |
* again by rebuilding the native resources with a subsequent call to |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1131 |
* {@code pack} or {@code show}. The states of the recreated |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1132 |
* {@code Window} and its subcomponents will be identical to the |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1133 |
* states of these objects at the point where the {@code Window} |
2 | 1134 |
* was disposed (not accounting for additional modifications between |
1135 |
* those actions). |
|
1136 |
* <p> |
|
1137 |
* <b>Note</b>: When the last displayable window |
|
1138 |
* within the Java virtual machine (VM) is disposed of, the VM may |
|
1139 |
* terminate. See <a href="doc-files/AWTThreadIssues.html#Autoshutdown"> |
|
1140 |
* AWT Threading Issues</a> for more information. |
|
1141 |
* @see Component#isDisplayable |
|
1142 |
* @see #pack |
|
1143 |
* @see #show |
|
1144 |
*/ |
|
1145 |
public void dispose() { |
|
1146 |
doDispose(); |
|
1147 |
} |
|
1148 |
||
1149 |
/* |
|
1150 |
* Fix for 4872170. |
|
1151 |
* If dispose() is called on parent then its children have to be disposed as well |
|
1152 |
* as reported in javadoc. So we need to implement this functionality even if a |
|
1153 |
* child overrides dispose() in a wrong way without calling super.dispose(). |
|
1154 |
*/ |
|
1155 |
void disposeImpl() { |
|
1156 |
dispose(); |
|
30469 | 1157 |
if (peer != null) { |
2 | 1158 |
doDispose(); |
1159 |
} |
|
1160 |
} |
|
1161 |
||
1162 |
void doDispose() { |
|
1163 |
class DisposeAction implements Runnable { |
|
1164 |
public void run() { |
|
11982
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1165 |
disposing = true; |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1166 |
try { |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1167 |
// Check if this window is the fullscreen window for the |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1168 |
// device. Exit the fullscreen mode prior to disposing |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1169 |
// of the window if that's the case. |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1170 |
GraphicsDevice gd = getGraphicsConfiguration().getDevice(); |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1171 |
if (gd.getFullScreenWindow() == Window.this) { |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1172 |
gd.setFullScreenWindow(null); |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1173 |
} |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1174 |
|
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1175 |
Object[] ownedWindowArray; |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1176 |
synchronized(ownedWindowList) { |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1177 |
ownedWindowArray = new Object[ownedWindowList.size()]; |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1178 |
ownedWindowList.copyInto(ownedWindowArray); |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1179 |
} |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1180 |
for (int i = 0; i < ownedWindowArray.length; i++) { |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1181 |
Window child = (Window) (((WeakReference) |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1182 |
(ownedWindowArray[i])).get()); |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1183 |
if (child != null) { |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1184 |
child.disposeImpl(); |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1185 |
} |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1186 |
} |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1187 |
hide(); |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1188 |
beforeFirstShow = true; |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1189 |
removeNotify(); |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1190 |
synchronized (inputContextLock) { |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1191 |
if (inputContext != null) { |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1192 |
inputContext.dispose(); |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1193 |
inputContext = null; |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1194 |
} |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1195 |
} |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1196 |
clearCurrentFocusCycleRootOnHide(); |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1197 |
} finally { |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
1198 |
disposing = false; |
2 | 1199 |
} |
1200 |
} |
|
1201 |
} |
|
17901
88326b660820
8015500: Prevent sending multiple WINDOW_CLOSED events for already disposed windows
anthony
parents:
17150
diff
changeset
|
1202 |
boolean fireWindowClosedEvent = isDisplayable(); |
2 | 1203 |
DisposeAction action = new DisposeAction(); |
1204 |
if (EventQueue.isDispatchThread()) { |
|
1205 |
action.run(); |
|
1206 |
} |
|
1207 |
else { |
|
1208 |
try { |
|
16092 | 1209 |
EventQueue.invokeAndWait(this, action); |
2 | 1210 |
} |
1211 |
catch (InterruptedException e) { |
|
1212 |
System.err.println("Disposal was interrupted:"); |
|
1213 |
e.printStackTrace(); |
|
1214 |
} |
|
1215 |
catch (InvocationTargetException e) { |
|
1216 |
System.err.println("Exception during disposal:"); |
|
1217 |
e.printStackTrace(); |
|
1218 |
} |
|
1219 |
} |
|
1220 |
// Execute outside the Runnable because postWindowEvent is |
|
1221 |
// synchronized on (this). We don't need to synchronize the call |
|
1222 |
// on the EventQueue anyways. |
|
17901
88326b660820
8015500: Prevent sending multiple WINDOW_CLOSED events for already disposed windows
anthony
parents:
17150
diff
changeset
|
1223 |
if (fireWindowClosedEvent) { |
88326b660820
8015500: Prevent sending multiple WINDOW_CLOSED events for already disposed windows
anthony
parents:
17150
diff
changeset
|
1224 |
postWindowEvent(WindowEvent.WINDOW_CLOSED); |
88326b660820
8015500: Prevent sending multiple WINDOW_CLOSED events for already disposed windows
anthony
parents:
17150
diff
changeset
|
1225 |
} |
2 | 1226 |
} |
1227 |
||
1228 |
/* |
|
1229 |
* Should only be called while holding the tree lock. |
|
1230 |
* It's overridden here because parent == owner in Window, |
|
1231 |
* and we shouldn't adjust counter on owner |
|
1232 |
*/ |
|
1233 |
void adjustListeningChildrenOnParent(long mask, int num) { |
|
1234 |
} |
|
1235 |
||
1236 |
// Should only be called while holding tree lock |
|
26749 | 1237 |
void adjustDescendantsOnParent(int num) { |
2 | 1238 |
// do nothing since parent == owner and we shouldn't |
26749 | 1239 |
// adjust counter on owner |
2 | 1240 |
} |
1241 |
||
1242 |
/** |
|
1243 |
* If this Window is visible, brings this Window to the front and may make |
|
1244 |
* it the focused Window. |
|
1245 |
* <p> |
|
1246 |
* Places this Window at the top of the stacking order and shows it in |
|
1247 |
* front of any other Windows in this VM. No action will take place if this |
|
1248 |
* Window is not visible. Some platforms do not allow Windows which own |
|
1249 |
* other Windows to appear on top of those owned Windows. Some platforms |
|
1250 |
* may not permit this VM to place its Windows above windows of native |
|
1251 |
* applications, or Windows of other VMs. This permission may depend on |
|
1252 |
* whether a Window in this VM is already focused. Every attempt will be |
|
1253 |
* made to move this Window as high as possible in the stacking order; |
|
1254 |
* however, developers should not assume that this method will move this |
|
1255 |
* Window above all other windows in every situation. |
|
1256 |
* <p> |
|
1257 |
* Developers must never assume that this Window is the focused or active |
|
1258 |
* Window until this Window receives a WINDOW_GAINED_FOCUS or WINDOW_ACTIVATED |
|
1259 |
* event. On platforms where the top-most window is the focused window, this |
|
1260 |
* method will <b>probably</b> focus this Window (if it is not already focused) |
|
1261 |
* under the following conditions: |
|
1262 |
* <ul> |
|
1263 |
* <li> The window meets the requirements outlined in the |
|
1264 |
* {@link #isFocusableWindow} method. |
|
1265 |
* <li> The window's property {@code autoRequestFocus} is of the |
|
1266 |
* {@code true} value. |
|
1267 |
* <li> Native windowing system allows the window to get focused. |
|
1268 |
* </ul> |
|
1269 |
* On platforms where the stacking order does not typically affect the focused |
|
1270 |
* window, this method will <b>probably</b> leave the focused and active |
|
1271 |
* Windows unchanged. |
|
1272 |
* <p> |
|
1273 |
* If this method causes this Window to be focused, and this Window is a |
|
1274 |
* Frame or a Dialog, it will also become activated. If this Window is |
|
1275 |
* focused, but it is not a Frame or a Dialog, then the first Frame or |
|
1276 |
* Dialog that is an owner of this Window will be activated. |
|
1277 |
* <p> |
|
1278 |
* If this window is blocked by modal dialog, then the blocking dialog |
|
1279 |
* is brought to the front and remains above the blocked window. |
|
1280 |
* |
|
1281 |
* @see #toBack |
|
1282 |
* @see #setAutoRequestFocus |
|
1283 |
* @see #isFocusableWindow |
|
1284 |
*/ |
|
1285 |
public void toFront() { |
|
1286 |
toFront_NoClientCode(); |
|
1287 |
} |
|
1288 |
||
1289 |
// This functionality is implemented in a final package-private method |
|
1290 |
// to insure that it cannot be overridden by client subclasses. |
|
1291 |
final void toFront_NoClientCode() { |
|
1292 |
if (visible) { |
|
1293 |
WindowPeer peer = (WindowPeer)this.peer; |
|
1294 |
if (peer != null) { |
|
1295 |
peer.toFront(); |
|
1296 |
} |
|
1297 |
if (isModalBlocked()) { |
|
1298 |
modalBlocker.toFront_NoClientCode(); |
|
1299 |
} |
|
1300 |
} |
|
1301 |
} |
|
1302 |
||
1303 |
/** |
|
1304 |
* If this Window is visible, sends this Window to the back and may cause |
|
1305 |
* it to lose focus or activation if it is the focused or active Window. |
|
1306 |
* <p> |
|
1307 |
* Places this Window at the bottom of the stacking order and shows it |
|
1308 |
* behind any other Windows in this VM. No action will take place is this |
|
1309 |
* Window is not visible. Some platforms do not allow Windows which are |
|
1310 |
* owned by other Windows to appear below their owners. Every attempt will |
|
1311 |
* be made to move this Window as low as possible in the stacking order; |
|
1312 |
* however, developers should not assume that this method will move this |
|
1313 |
* Window below all other windows in every situation. |
|
1314 |
* <p> |
|
1315 |
* Because of variations in native windowing systems, no guarantees about |
|
1316 |
* changes to the focused and active Windows can be made. Developers must |
|
1317 |
* never assume that this Window is no longer the focused or active Window |
|
1318 |
* until this Window receives a WINDOW_LOST_FOCUS or WINDOW_DEACTIVATED |
|
1319 |
* event. On platforms where the top-most window is the focused window, |
|
1320 |
* this method will <b>probably</b> cause this Window to lose focus. In |
|
1321 |
* that case, the next highest, focusable Window in this VM will receive |
|
1322 |
* focus. On platforms where the stacking order does not typically affect |
|
1323 |
* the focused window, this method will <b>probably</b> leave the focused |
|
1324 |
* and active Windows unchanged. |
|
1325 |
* |
|
1326 |
* @see #toFront |
|
1327 |
*/ |
|
1328 |
public void toBack() { |
|
1329 |
toBack_NoClientCode(); |
|
1330 |
} |
|
1331 |
||
1332 |
// This functionality is implemented in a final package-private method |
|
1333 |
// to insure that it cannot be overridden by client subclasses. |
|
1334 |
final void toBack_NoClientCode() { |
|
1335 |
if(isAlwaysOnTop()) { |
|
1336 |
try { |
|
1337 |
setAlwaysOnTop(false); |
|
1338 |
}catch(SecurityException e) { |
|
1339 |
} |
|
1340 |
} |
|
1341 |
if (visible) { |
|
1342 |
WindowPeer peer = (WindowPeer)this.peer; |
|
1343 |
if (peer != null) { |
|
1344 |
peer.toBack(); |
|
1345 |
} |
|
1346 |
} |
|
1347 |
} |
|
1348 |
||
1349 |
/** |
|
1350 |
* Returns the toolkit of this frame. |
|
1351 |
* @return the toolkit of this window. |
|
1352 |
* @see Toolkit |
|
1353 |
* @see Toolkit#getDefaultToolkit |
|
1354 |
* @see Component#getToolkit |
|
1355 |
*/ |
|
1356 |
public Toolkit getToolkit() { |
|
1357 |
return Toolkit.getDefaultToolkit(); |
|
1358 |
} |
|
1359 |
||
1360 |
/** |
|
1361 |
* Gets the warning string that is displayed with this window. |
|
1362 |
* If this window is insecure, the warning string is displayed |
|
1363 |
* somewhere in the visible area of the window. A window is |
|
19807
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
1364 |
* insecure if there is a security manager and the security |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
1365 |
* manager denies |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
1366 |
* {@code AWTPermission("showWindowWithoutWarningBanner")}. |
2 | 1367 |
* <p> |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1368 |
* If the window is secure, then {@code getWarningString} |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1369 |
* returns {@code null}. If the window is insecure, this |
2 | 1370 |
* method checks for the system property |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1371 |
* {@code awt.appletWarning} |
2 | 1372 |
* and returns the string value of that property. |
1373 |
* @return the warning string for this window. |
|
1374 |
*/ |
|
1375 |
public final String getWarningString() { |
|
1376 |
return warningString; |
|
1377 |
} |
|
1378 |
||
1379 |
private void setWarningString() { |
|
1380 |
warningString = null; |
|
1381 |
SecurityManager sm = System.getSecurityManager(); |
|
1382 |
if (sm != null) { |
|
19807
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
1383 |
try { |
22060
cd4f9d7dbeda
8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents:
21957
diff
changeset
|
1384 |
sm.checkPermission(AWTPermissions.TOPLEVEL_WINDOW_PERMISSION); |
19807
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
1385 |
} catch (SecurityException se) { |
2 | 1386 |
// make sure the privileged action is only |
1387 |
// for getting the property! We don't want the |
|
19807
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
19361
diff
changeset
|
1388 |
// above checkPermission call to always succeed! |
11813
643f5bef6ab4
7144475: fix some warnings in java.awt, javax.print.attribute.standard, and sun.beans.infos
chegar
parents:
9210
diff
changeset
|
1389 |
warningString = AccessController.doPrivileged( |
2 | 1390 |
new GetPropertyAction("awt.appletWarning", |
1391 |
"Java Applet Window")); |
|
1392 |
} |
|
1393 |
} |
|
1394 |
} |
|
1395 |
||
1396 |
/** |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1397 |
* Gets the {@code Locale} object that is associated |
2 | 1398 |
* with this window, if the locale has been set. |
1399 |
* If no locale has been set, then the default locale |
|
1400 |
* is returned. |
|
1401 |
* @return the locale that is set for this window. |
|
1402 |
* @see java.util.Locale |
|
24865
09b1d992ca72
8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents:
23717
diff
changeset
|
1403 |
* @since 1.1 |
2 | 1404 |
*/ |
1405 |
public Locale getLocale() { |
|
1406 |
if (this.locale == null) { |
|
1407 |
return Locale.getDefault(); |
|
1408 |
} |
|
1409 |
return this.locale; |
|
1410 |
} |
|
1411 |
||
1412 |
/** |
|
1413 |
* Gets the input context for this window. A window always has an input context, |
|
1414 |
* which is shared by subcomponents unless they create and set their own. |
|
1415 |
* @see Component#getInputContext |
|
1416 |
* @since 1.2 |
|
1417 |
*/ |
|
1418 |
public InputContext getInputContext() { |
|
1419 |
synchronized (inputContextLock) { |
|
1420 |
if (inputContext == null) { |
|
1421 |
inputContext = InputContext.getInstance(); |
|
1422 |
} |
|
1423 |
} |
|
1424 |
return inputContext; |
|
1425 |
} |
|
1426 |
||
1427 |
/** |
|
1428 |
* Set the cursor image to a specified cursor. |
|
1429 |
* <p> |
|
1430 |
* The method may have no visual effect if the Java platform |
|
1431 |
* implementation and/or the native system do not support |
|
1432 |
* changing the mouse cursor shape. |
|
1433 |
* @param cursor One of the constants defined |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1434 |
* by the {@code Cursor} class. If this parameter is null |
2 | 1435 |
* then the cursor for this window will be set to the type |
1436 |
* Cursor.DEFAULT_CURSOR. |
|
1437 |
* @see Component#getCursor |
|
1438 |
* @see Cursor |
|
24865
09b1d992ca72
8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents:
23717
diff
changeset
|
1439 |
* @since 1.1 |
2 | 1440 |
*/ |
1441 |
public void setCursor(Cursor cursor) { |
|
1442 |
if (cursor == null) { |
|
1443 |
cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); |
|
1444 |
} |
|
1445 |
super.setCursor(cursor); |
|
1446 |
} |
|
1447 |
||
1448 |
/** |
|
1449 |
* Returns the owner of this window. |
|
25162 | 1450 |
* |
1451 |
* @return the owner of this window |
|
2 | 1452 |
* @since 1.2 |
1453 |
*/ |
|
1454 |
public Window getOwner() { |
|
1455 |
return getOwner_NoClientCode(); |
|
1456 |
} |
|
1457 |
final Window getOwner_NoClientCode() { |
|
1458 |
return (Window)parent; |
|
1459 |
} |
|
1460 |
||
1461 |
/** |
|
1462 |
* Return an array containing all the windows this |
|
1463 |
* window currently owns. |
|
25162 | 1464 |
* |
1465 |
* @return the array of all the owned windows |
|
2 | 1466 |
* @since 1.2 |
1467 |
*/ |
|
1468 |
public Window[] getOwnedWindows() { |
|
1469 |
return getOwnedWindows_NoClientCode(); |
|
1470 |
} |
|
1471 |
final Window[] getOwnedWindows_NoClientCode() { |
|
1472 |
Window realCopy[]; |
|
1473 |
||
1474 |
synchronized(ownedWindowList) { |
|
1475 |
// Recall that ownedWindowList is actually a Vector of |
|
1476 |
// WeakReferences and calling get() on one of these references |
|
1477 |
// may return null. Make two arrays-- one the size of the |
|
1478 |
// Vector (fullCopy with size fullSize), and one the size of |
|
1479 |
// all non-null get()s (realCopy with size realSize). |
|
1480 |
int fullSize = ownedWindowList.size(); |
|
1481 |
int realSize = 0; |
|
1482 |
Window fullCopy[] = new Window[fullSize]; |
|
1483 |
||
1484 |
for (int i = 0; i < fullSize; i++) { |
|
1485 |
fullCopy[realSize] = ownedWindowList.elementAt(i).get(); |
|
1486 |
||
1487 |
if (fullCopy[realSize] != null) { |
|
1488 |
realSize++; |
|
1489 |
} |
|
1490 |
} |
|
1491 |
||
1492 |
if (fullSize != realSize) { |
|
1493 |
realCopy = Arrays.copyOf(fullCopy, realSize); |
|
1494 |
} else { |
|
1495 |
realCopy = fullCopy; |
|
1496 |
} |
|
1497 |
} |
|
1498 |
||
1499 |
return realCopy; |
|
1500 |
} |
|
1501 |
||
1502 |
boolean isModalBlocked() { |
|
1503 |
return modalBlocker != null; |
|
1504 |
} |
|
1505 |
||
1506 |
void setModalBlocked(Dialog blocker, boolean blocked, boolean peerCall) { |
|
1507 |
this.modalBlocker = blocked ? blocker : null; |
|
1508 |
if (peerCall) { |
|
1509 |
WindowPeer peer = (WindowPeer)this.peer; |
|
1510 |
if (peer != null) { |
|
1511 |
peer.setModalBlocked(blocker, blocked); |
|
1512 |
} |
|
1513 |
} |
|
1514 |
} |
|
1515 |
||
1516 |
Dialog getModalBlocker() { |
|
1517 |
return modalBlocker; |
|
1518 |
} |
|
1519 |
||
1520 |
/* |
|
1521 |
* Returns a list of all displayable Windows, i. e. all the |
|
1522 |
* Windows which peer is not null. |
|
1523 |
* |
|
1524 |
* @see #addNotify |
|
1525 |
* @see #removeNotify |
|
1526 |
*/ |
|
1527 |
static IdentityArrayList<Window> getAllWindows() { |
|
1528 |
synchronized (allWindows) { |
|
1529 |
IdentityArrayList<Window> v = new IdentityArrayList<Window>(); |
|
1530 |
v.addAll(allWindows); |
|
1531 |
return v; |
|
1532 |
} |
|
1533 |
} |
|
1534 |
||
1535 |
static IdentityArrayList<Window> getAllUnblockedWindows() { |
|
1536 |
synchronized (allWindows) { |
|
1537 |
IdentityArrayList<Window> unblocked = new IdentityArrayList<Window>(); |
|
1538 |
for (int i = 0; i < allWindows.size(); i++) { |
|
1539 |
Window w = allWindows.get(i); |
|
1540 |
if (!w.isModalBlocked()) { |
|
1541 |
unblocked.add(w); |
|
1542 |
} |
|
1543 |
} |
|
1544 |
return unblocked; |
|
1545 |
} |
|
1546 |
} |
|
1547 |
||
1548 |
private static Window[] getWindows(AppContext appContext) { |
|
1549 |
synchronized (Window.class) { |
|
1550 |
Window realCopy[]; |
|
15318
607db339afcc
8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents:
12661
diff
changeset
|
1551 |
@SuppressWarnings("unchecked") |
2 | 1552 |
Vector<WeakReference<Window>> windowList = |
1553 |
(Vector<WeakReference<Window>>)appContext.get(Window.class); |
|
1554 |
if (windowList != null) { |
|
1555 |
int fullSize = windowList.size(); |
|
1556 |
int realSize = 0; |
|
1557 |
Window fullCopy[] = new Window[fullSize]; |
|
1558 |
for (int i = 0; i < fullSize; i++) { |
|
1559 |
Window w = windowList.get(i).get(); |
|
1560 |
if (w != null) { |
|
1561 |
fullCopy[realSize++] = w; |
|
1562 |
} |
|
1563 |
} |
|
1564 |
if (fullSize != realSize) { |
|
1565 |
realCopy = Arrays.copyOf(fullCopy, realSize); |
|
1566 |
} else { |
|
1567 |
realCopy = fullCopy; |
|
1568 |
} |
|
1569 |
} else { |
|
1570 |
realCopy = new Window[0]; |
|
1571 |
} |
|
1572 |
return realCopy; |
|
1573 |
} |
|
1574 |
} |
|
1575 |
||
1576 |
/** |
|
1577 |
* Returns an array of all {@code Window}s, both owned and ownerless, |
|
1578 |
* created by this application. |
|
1579 |
* If called from an applet, the array includes only the {@code Window}s |
|
1580 |
* accessible by that applet. |
|
1581 |
* <p> |
|
1582 |
* <b>Warning:</b> this method may return system created windows, such |
|
1583 |
* as a print dialog. Applications should not assume the existence of |
|
1584 |
* these dialogs, nor should an application assume anything about these |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1585 |
* dialogs such as component positions, {@code LayoutManager}s |
2 | 1586 |
* or serialization. |
1587 |
* |
|
25162 | 1588 |
* @return the array of all the {@code Window}s created by the application |
2 | 1589 |
* @see Frame#getFrames |
1590 |
* @see Window#getOwnerlessWindows |
|
1591 |
* |
|
1592 |
* @since 1.6 |
|
1593 |
*/ |
|
1594 |
public static Window[] getWindows() { |
|
1595 |
return getWindows(AppContext.getAppContext()); |
|
1596 |
} |
|
1597 |
||
1598 |
/** |
|
1599 |
* Returns an array of all {@code Window}s created by this application |
|
1600 |
* that have no owner. They include {@code Frame}s and ownerless |
|
1601 |
* {@code Dialog}s and {@code Window}s. |
|
1602 |
* If called from an applet, the array includes only the {@code Window}s |
|
1603 |
* accessible by that applet. |
|
1604 |
* <p> |
|
1605 |
* <b>Warning:</b> this method may return system created windows, such |
|
1606 |
* as a print dialog. Applications should not assume the existence of |
|
1607 |
* these dialogs, nor should an application assume anything about these |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1608 |
* dialogs such as component positions, {@code LayoutManager}s |
2 | 1609 |
* or serialization. |
1610 |
* |
|
25162 | 1611 |
* @return the array of all the ownerless {@code Window}s |
1612 |
* created by this application |
|
2 | 1613 |
* @see Frame#getFrames |
1614 |
* @see Window#getWindows() |
|
1615 |
* |
|
1616 |
* @since 1.6 |
|
1617 |
*/ |
|
1618 |
public static Window[] getOwnerlessWindows() { |
|
1619 |
Window[] allWindows = Window.getWindows(); |
|
1620 |
||
1621 |
int ownerlessCount = 0; |
|
1622 |
for (Window w : allWindows) { |
|
1623 |
if (w.getOwner() == null) { |
|
1624 |
ownerlessCount++; |
|
1625 |
} |
|
1626 |
} |
|
1627 |
||
1628 |
Window[] ownerless = new Window[ownerlessCount]; |
|
1629 |
int c = 0; |
|
1630 |
for (Window w : allWindows) { |
|
1631 |
if (w.getOwner() == null) { |
|
1632 |
ownerless[c++] = w; |
|
1633 |
} |
|
1634 |
} |
|
1635 |
||
1636 |
return ownerless; |
|
1637 |
} |
|
1638 |
||
1639 |
Window getDocumentRoot() { |
|
1640 |
synchronized (getTreeLock()) { |
|
1641 |
Window w = this; |
|
1642 |
while (w.getOwner() != null) { |
|
1643 |
w = w.getOwner(); |
|
1644 |
} |
|
1645 |
return w; |
|
1646 |
} |
|
1647 |
} |
|
1648 |
||
1649 |
/** |
|
1650 |
* Specifies the modal exclusion type for this window. If a window is modal |
|
1651 |
* excluded, it is not blocked by some modal dialogs. See {@link |
|
1652 |
* java.awt.Dialog.ModalExclusionType Dialog.ModalExclusionType} for |
|
1653 |
* possible modal exclusion types. |
|
1654 |
* <p> |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1655 |
* If the given type is not supported, {@code NO_EXCLUDE} is used. |
2 | 1656 |
* <p> |
1657 |
* Note: changing the modal exclusion type for a visible window may have no |
|
1658 |
* effect until it is hidden and then shown again. |
|
1659 |
* |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1660 |
* @param exclusionType the modal exclusion type for this window; a {@code null} |
21278 | 1661 |
* value is equivalent to {@link Dialog.ModalExclusionType#NO_EXCLUDE |
2 | 1662 |
* NO_EXCLUDE} |
1663 |
* @throws SecurityException if the calling thread does not have permission |
|
1664 |
* to set the modal exclusion property to the window with the given |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1665 |
* {@code exclusionType} |
2 | 1666 |
* @see java.awt.Dialog.ModalExclusionType |
1667 |
* @see java.awt.Window#getModalExclusionType |
|
1668 |
* @see java.awt.Toolkit#isModalExclusionTypeSupported |
|
1669 |
* |
|
1670 |
* @since 1.6 |
|
1671 |
*/ |
|
1672 |
public void setModalExclusionType(Dialog.ModalExclusionType exclusionType) { |
|
1673 |
if (exclusionType == null) { |
|
1674 |
exclusionType = Dialog.ModalExclusionType.NO_EXCLUDE; |
|
1675 |
} |
|
1676 |
if (!Toolkit.getDefaultToolkit().isModalExclusionTypeSupported(exclusionType)) { |
|
1677 |
exclusionType = Dialog.ModalExclusionType.NO_EXCLUDE; |
|
1678 |
} |
|
1679 |
if (modalExclusionType == exclusionType) { |
|
1680 |
return; |
|
1681 |
} |
|
1682 |
if (exclusionType == Dialog.ModalExclusionType.TOOLKIT_EXCLUDE) { |
|
1683 |
SecurityManager sm = System.getSecurityManager(); |
|
1684 |
if (sm != null) { |
|
22060
cd4f9d7dbeda
8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents:
21957
diff
changeset
|
1685 |
sm.checkPermission(AWTPermissions.TOOLKIT_MODALITY_PERMISSION); |
2 | 1686 |
} |
1687 |
} |
|
1688 |
modalExclusionType = exclusionType; |
|
1689 |
||
1690 |
// if we want on-fly changes, we need to uncomment the lines below |
|
1691 |
// and override the method in Dialog to use modalShow() instead |
|
1692 |
// of updateChildrenBlocking() |
|
1693 |
/* |
|
1694 |
if (isModalBlocked()) { |
|
1695 |
modalBlocker.unblockWindow(this); |
|
1696 |
} |
|
1697 |
Dialog.checkShouldBeBlocked(this); |
|
1698 |
updateChildrenBlocking(); |
|
1699 |
*/ |
|
1700 |
} |
|
1701 |
||
1702 |
/** |
|
1703 |
* Returns the modal exclusion type of this window. |
|
1704 |
* |
|
1705 |
* @return the modal exclusion type of this window |
|
1706 |
* |
|
1707 |
* @see java.awt.Dialog.ModalExclusionType |
|
1708 |
* @see java.awt.Window#setModalExclusionType |
|
1709 |
* |
|
1710 |
* @since 1.6 |
|
1711 |
*/ |
|
1712 |
public Dialog.ModalExclusionType getModalExclusionType() { |
|
1713 |
return modalExclusionType; |
|
1714 |
} |
|
1715 |
||
1716 |
boolean isModalExcluded(Dialog.ModalExclusionType exclusionType) { |
|
1717 |
if ((modalExclusionType != null) && |
|
1718 |
modalExclusionType.compareTo(exclusionType) >= 0) |
|
1719 |
{ |
|
1720 |
return true; |
|
1721 |
} |
|
1722 |
Window owner = getOwner_NoClientCode(); |
|
1723 |
return (owner != null) && owner.isModalExcluded(exclusionType); |
|
1724 |
} |
|
1725 |
||
1726 |
void updateChildrenBlocking() { |
|
1727 |
Vector<Window> childHierarchy = new Vector<Window>(); |
|
1728 |
Window[] ownedWindows = getOwnedWindows(); |
|
1729 |
for (int i = 0; i < ownedWindows.length; i++) { |
|
1730 |
childHierarchy.add(ownedWindows[i]); |
|
1731 |
} |
|
1732 |
int k = 0; |
|
1733 |
while (k < childHierarchy.size()) { |
|
1734 |
Window w = childHierarchy.get(k); |
|
1735 |
if (w.isVisible()) { |
|
1736 |
if (w.isModalBlocked()) { |
|
1737 |
Dialog blocker = w.getModalBlocker(); |
|
1738 |
blocker.unblockWindow(w); |
|
1739 |
} |
|
1740 |
Dialog.checkShouldBeBlocked(w); |
|
1741 |
Window[] wOwned = w.getOwnedWindows(); |
|
1742 |
for (int j = 0; j < wOwned.length; j++) { |
|
1743 |
childHierarchy.add(wOwned[j]); |
|
1744 |
} |
|
1745 |
} |
|
1746 |
k++; |
|
1747 |
} |
|
1748 |
} |
|
1749 |
||
1750 |
/** |
|
1751 |
* Adds the specified window listener to receive window events from |
|
1752 |
* this window. |
|
1753 |
* If l is null, no exception is thrown and no action is performed. |
|
1754 |
* <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads" |
|
1755 |
* >AWT Threading Issues</a> for details on AWT's threading model. |
|
1756 |
* |
|
1757 |
* @param l the window listener |
|
1758 |
* @see #removeWindowListener |
|
1759 |
* @see #getWindowListeners |
|
1760 |
*/ |
|
1761 |
public synchronized void addWindowListener(WindowListener l) { |
|
1762 |
if (l == null) { |
|
1763 |
return; |
|
1764 |
} |
|
1765 |
newEventsOnly = true; |
|
1766 |
windowListener = AWTEventMulticaster.add(windowListener, l); |
|
1767 |
} |
|
1768 |
||
1769 |
/** |
|
1770 |
* Adds the specified window state listener to receive window |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1771 |
* events from this window. If {@code l} is {@code null}, |
2 | 1772 |
* no exception is thrown and no action is performed. |
1773 |
* <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads" |
|
1774 |
* >AWT Threading Issues</a> for details on AWT's threading model. |
|
1775 |
* |
|
1776 |
* @param l the window state listener |
|
1777 |
* @see #removeWindowStateListener |
|
1778 |
* @see #getWindowStateListeners |
|
1779 |
* @since 1.4 |
|
1780 |
*/ |
|
1781 |
public synchronized void addWindowStateListener(WindowStateListener l) { |
|
1782 |
if (l == null) { |
|
1783 |
return; |
|
1784 |
} |
|
1785 |
windowStateListener = AWTEventMulticaster.add(windowStateListener, l); |
|
1786 |
newEventsOnly = true; |
|
1787 |
} |
|
1788 |
||
1789 |
/** |
|
1790 |
* Adds the specified window focus listener to receive window events |
|
1791 |
* from this window. |
|
1792 |
* If l is null, no exception is thrown and no action is performed. |
|
1793 |
* <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads" |
|
1794 |
* >AWT Threading Issues</a> for details on AWT's threading model. |
|
1795 |
* |
|
1796 |
* @param l the window focus listener |
|
1797 |
* @see #removeWindowFocusListener |
|
1798 |
* @see #getWindowFocusListeners |
|
1799 |
* @since 1.4 |
|
1800 |
*/ |
|
1801 |
public synchronized void addWindowFocusListener(WindowFocusListener l) { |
|
1802 |
if (l == null) { |
|
1803 |
return; |
|
1804 |
} |
|
1805 |
windowFocusListener = AWTEventMulticaster.add(windowFocusListener, l); |
|
1806 |
newEventsOnly = true; |
|
1807 |
} |
|
1808 |
||
1809 |
/** |
|
1810 |
* Removes the specified window listener so that it no longer |
|
1811 |
* receives window events from this window. |
|
1812 |
* If l is null, no exception is thrown and no action is performed. |
|
1813 |
* <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads" |
|
1814 |
* >AWT Threading Issues</a> for details on AWT's threading model. |
|
1815 |
* |
|
1816 |
* @param l the window listener |
|
1817 |
* @see #addWindowListener |
|
1818 |
* @see #getWindowListeners |
|
1819 |
*/ |
|
1820 |
public synchronized void removeWindowListener(WindowListener l) { |
|
1821 |
if (l == null) { |
|
1822 |
return; |
|
1823 |
} |
|
1824 |
windowListener = AWTEventMulticaster.remove(windowListener, l); |
|
1825 |
} |
|
1826 |
||
1827 |
/** |
|
1828 |
* Removes the specified window state listener so that it no |
|
1829 |
* longer receives window events from this window. If |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1830 |
* {@code l} is {@code null}, no exception is thrown and |
2 | 1831 |
* no action is performed. |
1832 |
* <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads" |
|
1833 |
* >AWT Threading Issues</a> for details on AWT's threading model. |
|
1834 |
* |
|
1835 |
* @param l the window state listener |
|
1836 |
* @see #addWindowStateListener |
|
1837 |
* @see #getWindowStateListeners |
|
1838 |
* @since 1.4 |
|
1839 |
*/ |
|
1840 |
public synchronized void removeWindowStateListener(WindowStateListener l) { |
|
1841 |
if (l == null) { |
|
1842 |
return; |
|
1843 |
} |
|
1844 |
windowStateListener = AWTEventMulticaster.remove(windowStateListener, l); |
|
1845 |
} |
|
1846 |
||
1847 |
/** |
|
1848 |
* Removes the specified window focus listener so that it no longer |
|
1849 |
* receives window events from this window. |
|
1850 |
* If l is null, no exception is thrown and no action is performed. |
|
1851 |
* <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads" |
|
1852 |
* >AWT Threading Issues</a> for details on AWT's threading model. |
|
1853 |
* |
|
1854 |
* @param l the window focus listener |
|
1855 |
* @see #addWindowFocusListener |
|
1856 |
* @see #getWindowFocusListeners |
|
1857 |
* @since 1.4 |
|
1858 |
*/ |
|
1859 |
public synchronized void removeWindowFocusListener(WindowFocusListener l) { |
|
1860 |
if (l == null) { |
|
1861 |
return; |
|
1862 |
} |
|
1863 |
windowFocusListener = AWTEventMulticaster.remove(windowFocusListener, l); |
|
1864 |
} |
|
1865 |
||
1866 |
/** |
|
1867 |
* Returns an array of all the window listeners |
|
1868 |
* registered on this window. |
|
1869 |
* |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1870 |
* @return all of this window's {@code WindowListener}s |
2 | 1871 |
* or an empty array if no window |
1872 |
* listeners are currently registered |
|
1873 |
* |
|
1874 |
* @see #addWindowListener |
|
1875 |
* @see #removeWindowListener |
|
1876 |
* @since 1.4 |
|
1877 |
*/ |
|
1878 |
public synchronized WindowListener[] getWindowListeners() { |
|
15318
607db339afcc
8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents:
12661
diff
changeset
|
1879 |
return getListeners(WindowListener.class); |
2 | 1880 |
} |
1881 |
||
1882 |
/** |
|
1883 |
* Returns an array of all the window focus listeners |
|
1884 |
* registered on this window. |
|
1885 |
* |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1886 |
* @return all of this window's {@code WindowFocusListener}s |
2 | 1887 |
* or an empty array if no window focus |
1888 |
* listeners are currently registered |
|
1889 |
* |
|
1890 |
* @see #addWindowFocusListener |
|
1891 |
* @see #removeWindowFocusListener |
|
1892 |
* @since 1.4 |
|
1893 |
*/ |
|
1894 |
public synchronized WindowFocusListener[] getWindowFocusListeners() { |
|
15318
607db339afcc
8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents:
12661
diff
changeset
|
1895 |
return getListeners(WindowFocusListener.class); |
2 | 1896 |
} |
1897 |
||
1898 |
/** |
|
1899 |
* Returns an array of all the window state listeners |
|
1900 |
* registered on this window. |
|
1901 |
* |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1902 |
* @return all of this window's {@code WindowStateListener}s |
2 | 1903 |
* or an empty array if no window state |
1904 |
* listeners are currently registered |
|
1905 |
* |
|
1906 |
* @see #addWindowStateListener |
|
1907 |
* @see #removeWindowStateListener |
|
1908 |
* @since 1.4 |
|
1909 |
*/ |
|
1910 |
public synchronized WindowStateListener[] getWindowStateListeners() { |
|
15318
607db339afcc
8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents:
12661
diff
changeset
|
1911 |
return getListeners(WindowStateListener.class); |
2 | 1912 |
} |
1913 |
||
1914 |
||
1915 |
/** |
|
1916 |
* Returns an array of all the objects currently registered |
|
1917 |
* as <code><em>Foo</em>Listener</code>s |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1918 |
* upon this {@code Window}. |
2 | 1919 |
* <code><em>Foo</em>Listener</code>s are registered using the |
1920 |
* <code>add<em>Foo</em>Listener</code> method. |
|
1921 |
* |
|
1922 |
* <p> |
|
1923 |
* |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1924 |
* You can specify the {@code listenerType} argument |
2 | 1925 |
* with a class literal, such as |
1926 |
* <code><em>Foo</em>Listener.class</code>. |
|
1927 |
* For example, you can query a |
|
35667 | 1928 |
* {@code Window w} |
2 | 1929 |
* for its window listeners with the following code: |
1930 |
* |
|
1931 |
* <pre>WindowListener[] wls = (WindowListener[])(w.getListeners(WindowListener.class));</pre> |
|
1932 |
* |
|
1933 |
* If no such listeners exist, this method returns an empty array. |
|
1934 |
* |
|
1935 |
* @param listenerType the type of listeners requested; this parameter |
|
1936 |
* should specify an interface that descends from |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1937 |
* {@code java.util.EventListener} |
2 | 1938 |
* @return an array of all objects registered as |
1939 |
* <code><em>Foo</em>Listener</code>s on this window, |
|
1940 |
* or an empty array if no such |
|
1941 |
* listeners have been added |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1942 |
* @exception ClassCastException if {@code listenerType} |
2 | 1943 |
* doesn't specify a class or interface that implements |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
1944 |
* {@code java.util.EventListener} |
7154
4e8371f358ac
6877895: Some AWT's methods should specify throwing NPE for null arg value
dcherepanov
parents:
6823
diff
changeset
|
1945 |
* @exception NullPointerException if {@code listenerType} is {@code null} |
2 | 1946 |
* |
1947 |
* @see #getWindowListeners |
|
1948 |
* @since 1.3 |
|
1949 |
*/ |
|
1950 |
public <T extends EventListener> T[] getListeners(Class<T> listenerType) { |
|
1951 |
EventListener l = null; |
|
1952 |
if (listenerType == WindowFocusListener.class) { |
|
1953 |
l = windowFocusListener; |
|
1954 |
} else if (listenerType == WindowStateListener.class) { |
|
1955 |
l = windowStateListener; |
|
1956 |
} else if (listenerType == WindowListener.class) { |
|
1957 |
l = windowListener; |
|
1958 |
} else { |
|
1959 |
return super.getListeners(listenerType); |
|
1960 |
} |
|
1961 |
return AWTEventMulticaster.getListeners(l, listenerType); |
|
1962 |
} |
|
1963 |
||
1964 |
// REMIND: remove when filtering is handled at lower level |
|
1965 |
boolean eventEnabled(AWTEvent e) { |
|
1966 |
switch(e.id) { |
|
1967 |
case WindowEvent.WINDOW_OPENED: |
|
1968 |
case WindowEvent.WINDOW_CLOSING: |
|
1969 |
case WindowEvent.WINDOW_CLOSED: |
|
1970 |
case WindowEvent.WINDOW_ICONIFIED: |
|
1971 |
case WindowEvent.WINDOW_DEICONIFIED: |
|
1972 |
case WindowEvent.WINDOW_ACTIVATED: |
|
1973 |
case WindowEvent.WINDOW_DEACTIVATED: |
|
1974 |
if ((eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0 || |
|
1975 |
windowListener != null) { |
|
1976 |
return true; |
|
1977 |
} |
|
1978 |
return false; |
|
1979 |
case WindowEvent.WINDOW_GAINED_FOCUS: |
|
1980 |
case WindowEvent.WINDOW_LOST_FOCUS: |
|
1981 |
if ((eventMask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0 || |
|
1982 |
windowFocusListener != null) { |
|
1983 |
return true; |
|
1984 |
} |
|
1985 |
return false; |
|
1986 |
case WindowEvent.WINDOW_STATE_CHANGED: |
|
1987 |
if ((eventMask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0 || |
|
1988 |
windowStateListener != null) { |
|
1989 |
return true; |
|
1990 |
} |
|
1991 |
return false; |
|
1992 |
default: |
|
1993 |
break; |
|
1994 |
} |
|
1995 |
return super.eventEnabled(e); |
|
1996 |
} |
|
1997 |
||
1998 |
/** |
|
1999 |
* Processes events on this window. If the event is an |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2000 |
* {@code WindowEvent}, it invokes the |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2001 |
* {@code processWindowEvent} method, else it invokes its |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2002 |
* superclass's {@code processEvent}. |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2003 |
* <p>Note that if the event parameter is {@code null} |
2 | 2004 |
* the behavior is unspecified and may result in an |
2005 |
* exception. |
|
2006 |
* |
|
2007 |
* @param e the event |
|
2008 |
*/ |
|
2009 |
protected void processEvent(AWTEvent e) { |
|
2010 |
if (e instanceof WindowEvent) { |
|
2011 |
switch (e.getID()) { |
|
2012 |
case WindowEvent.WINDOW_OPENED: |
|
2013 |
case WindowEvent.WINDOW_CLOSING: |
|
2014 |
case WindowEvent.WINDOW_CLOSED: |
|
2015 |
case WindowEvent.WINDOW_ICONIFIED: |
|
2016 |
case WindowEvent.WINDOW_DEICONIFIED: |
|
2017 |
case WindowEvent.WINDOW_ACTIVATED: |
|
2018 |
case WindowEvent.WINDOW_DEACTIVATED: |
|
2019 |
processWindowEvent((WindowEvent)e); |
|
2020 |
break; |
|
2021 |
case WindowEvent.WINDOW_GAINED_FOCUS: |
|
2022 |
case WindowEvent.WINDOW_LOST_FOCUS: |
|
2023 |
processWindowFocusEvent((WindowEvent)e); |
|
2024 |
break; |
|
2025 |
case WindowEvent.WINDOW_STATE_CHANGED: |
|
2026 |
processWindowStateEvent((WindowEvent)e); |
|
2027 |
break; |
|
2028 |
} |
|
2029 |
return; |
|
2030 |
} |
|
2031 |
super.processEvent(e); |
|
2032 |
} |
|
2033 |
||
2034 |
/** |
|
2035 |
* Processes window events occurring on this window by |
|
2036 |
* dispatching them to any registered WindowListener objects. |
|
2037 |
* NOTE: This method will not be called unless window events |
|
2038 |
* are enabled for this component; this happens when one of the |
|
2039 |
* following occurs: |
|
2040 |
* <ul> |
|
2041 |
* <li>A WindowListener object is registered via |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2042 |
* {@code addWindowListener} |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2043 |
* <li>Window events are enabled via {@code enableEvents} |
2 | 2044 |
* </ul> |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2045 |
* <p>Note that if the event parameter is {@code null} |
2 | 2046 |
* the behavior is unspecified and may result in an |
2047 |
* exception. |
|
2048 |
* |
|
2049 |
* @param e the window event |
|
2050 |
* @see Component#enableEvents |
|
2051 |
*/ |
|
2052 |
protected void processWindowEvent(WindowEvent e) { |
|
2053 |
WindowListener listener = windowListener; |
|
2054 |
if (listener != null) { |
|
2055 |
switch(e.getID()) { |
|
2056 |
case WindowEvent.WINDOW_OPENED: |
|
2057 |
listener.windowOpened(e); |
|
2058 |
break; |
|
2059 |
case WindowEvent.WINDOW_CLOSING: |
|
2060 |
listener.windowClosing(e); |
|
2061 |
break; |
|
2062 |
case WindowEvent.WINDOW_CLOSED: |
|
2063 |
listener.windowClosed(e); |
|
2064 |
break; |
|
2065 |
case WindowEvent.WINDOW_ICONIFIED: |
|
2066 |
listener.windowIconified(e); |
|
2067 |
break; |
|
2068 |
case WindowEvent.WINDOW_DEICONIFIED: |
|
2069 |
listener.windowDeiconified(e); |
|
2070 |
break; |
|
2071 |
case WindowEvent.WINDOW_ACTIVATED: |
|
2072 |
listener.windowActivated(e); |
|
2073 |
break; |
|
2074 |
case WindowEvent.WINDOW_DEACTIVATED: |
|
2075 |
listener.windowDeactivated(e); |
|
2076 |
break; |
|
2077 |
default: |
|
2078 |
break; |
|
2079 |
} |
|
2080 |
} |
|
2081 |
} |
|
2082 |
||
2083 |
/** |
|
21278 | 2084 |
* Processes window focus event occurring on this window by |
2 | 2085 |
* dispatching them to any registered WindowFocusListener objects. |
2086 |
* NOTE: this method will not be called unless window focus events |
|
2087 |
* are enabled for this window. This happens when one of the |
|
2088 |
* following occurs: |
|
2089 |
* <ul> |
|
2090 |
* <li>a WindowFocusListener is registered via |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2091 |
* {@code addWindowFocusListener} |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2092 |
* <li>Window focus events are enabled via {@code enableEvents} |
2 | 2093 |
* </ul> |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2094 |
* <p>Note that if the event parameter is {@code null} |
2 | 2095 |
* the behavior is unspecified and may result in an |
2096 |
* exception. |
|
2097 |
* |
|
2098 |
* @param e the window focus event |
|
2099 |
* @see Component#enableEvents |
|
2100 |
* @since 1.4 |
|
2101 |
*/ |
|
2102 |
protected void processWindowFocusEvent(WindowEvent e) { |
|
2103 |
WindowFocusListener listener = windowFocusListener; |
|
2104 |
if (listener != null) { |
|
2105 |
switch (e.getID()) { |
|
2106 |
case WindowEvent.WINDOW_GAINED_FOCUS: |
|
2107 |
listener.windowGainedFocus(e); |
|
2108 |
break; |
|
2109 |
case WindowEvent.WINDOW_LOST_FOCUS: |
|
2110 |
listener.windowLostFocus(e); |
|
2111 |
break; |
|
2112 |
default: |
|
2113 |
break; |
|
2114 |
} |
|
2115 |
} |
|
2116 |
} |
|
2117 |
||
2118 |
/** |
|
21278 | 2119 |
* Processes window state event occurring on this window by |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2120 |
* dispatching them to any registered {@code WindowStateListener} |
2 | 2121 |
* objects. |
2122 |
* NOTE: this method will not be called unless window state events |
|
2123 |
* are enabled for this window. This happens when one of the |
|
2124 |
* following occurs: |
|
2125 |
* <ul> |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2126 |
* <li>a {@code WindowStateListener} is registered via |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2127 |
* {@code addWindowStateListener} |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2128 |
* <li>window state events are enabled via {@code enableEvents} |
2 | 2129 |
* </ul> |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2130 |
* <p>Note that if the event parameter is {@code null} |
2 | 2131 |
* the behavior is unspecified and may result in an |
2132 |
* exception. |
|
2133 |
* |
|
2134 |
* @param e the window state event |
|
2135 |
* @see java.awt.Component#enableEvents |
|
2136 |
* @since 1.4 |
|
2137 |
*/ |
|
2138 |
protected void processWindowStateEvent(WindowEvent e) { |
|
2139 |
WindowStateListener listener = windowStateListener; |
|
2140 |
if (listener != null) { |
|
2141 |
switch (e.getID()) { |
|
2142 |
case WindowEvent.WINDOW_STATE_CHANGED: |
|
2143 |
listener.windowStateChanged(e); |
|
2144 |
break; |
|
2145 |
default: |
|
2146 |
break; |
|
2147 |
} |
|
2148 |
} |
|
2149 |
} |
|
2150 |
||
2151 |
/** |
|
2152 |
* Implements a debugging hook -- checks to see if |
|
2153 |
* the user has typed <i>control-shift-F1</i>. If so, |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2154 |
* the list of child windows is dumped to {@code System.out}. |
2 | 2155 |
* @param e the keyboard event |
2156 |
*/ |
|
2157 |
void preProcessKeyEvent(KeyEvent e) { |
|
32294
58789f875b54
4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
30471
diff
changeset
|
2158 |
// Dump the list of child windows to System.out if debug is enabled. |
58789f875b54
4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
30471
diff
changeset
|
2159 |
if (DebugSettings.getInstance().getBoolean("on", false)) { |
58789f875b54
4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
30471
diff
changeset
|
2160 |
if (e.isActionKey() && e.getKeyCode() == KeyEvent.VK_F1 && |
58789f875b54
4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
30471
diff
changeset
|
2161 |
e.isControlDown() && e.isShiftDown() && |
58789f875b54
4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
30471
diff
changeset
|
2162 |
e.getID() == KeyEvent.KEY_PRESSED) { |
58789f875b54
4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
30471
diff
changeset
|
2163 |
list(System.out, 0); |
58789f875b54
4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
30471
diff
changeset
|
2164 |
} |
2 | 2165 |
} |
2166 |
} |
|
2167 |
||
2168 |
void postProcessKeyEvent(KeyEvent e) { |
|
2169 |
// Do nothing |
|
2170 |
} |
|
2171 |
||
2172 |
||
2173 |
/** |
|
2174 |
* Sets whether this window should always be above other windows. If |
|
2175 |
* there are multiple always-on-top windows, their relative order is |
|
2176 |
* unspecified and platform dependent. |
|
2177 |
* <p> |
|
2178 |
* If some other window is already always-on-top then the |
|
2179 |
* relative order between these windows is unspecified (depends on |
|
2180 |
* platform). No window can be brought to be over the always-on-top |
|
2181 |
* window except maybe another always-on-top window. |
|
2182 |
* <p> |
|
2183 |
* All windows owned by an always-on-top window inherit this state and |
|
2184 |
* automatically become always-on-top. If a window ceases to be |
|
2185 |
* always-on-top, the windows that it owns will no longer be |
|
2186 |
* always-on-top. When an always-on-top window is sent {@link #toBack |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2187 |
* toBack}, its always-on-top state is set to {@code false}. |
2 | 2188 |
* |
2189 |
* <p> When this method is called on a window with a value of |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2190 |
* {@code true}, and the window is visible and the platform |
2 | 2191 |
* supports always-on-top for this window, the window is immediately |
2192 |
* brought forward, "sticking" it in the top-most position. If the |
|
2193 |
* window isn`t currently visible, this method sets the always-on-top |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2194 |
* state to {@code true} but does not bring the window forward. |
2 | 2195 |
* When the window is later shown, it will be always-on-top. |
2196 |
* |
|
2197 |
* <p> When this method is called on a window with a value of |
|
21262
88e6e648168e
8025225: Window.setAlwaysOnTop documentation should be updated
serb
parents:
20467
diff
changeset
|
2198 |
* {@code false} the always-on-top state is set to normal. It may also |
88e6e648168e
8025225: Window.setAlwaysOnTop documentation should be updated
serb
parents:
20467
diff
changeset
|
2199 |
* cause an unspecified, platform-dependent change in the z-order of |
88e6e648168e
8025225: Window.setAlwaysOnTop documentation should be updated
serb
parents:
20467
diff
changeset
|
2200 |
* top-level windows, but other always-on-top windows will remain in |
88e6e648168e
8025225: Window.setAlwaysOnTop documentation should be updated
serb
parents:
20467
diff
changeset
|
2201 |
* top-most position. Calling this method with a value of {@code false} |
88e6e648168e
8025225: Window.setAlwaysOnTop documentation should be updated
serb
parents:
20467
diff
changeset
|
2202 |
* on a window that has a normal state has no effect. |
2 | 2203 |
* |
2204 |
* <p><b>Note</b>: some platforms might not support always-on-top |
|
2205 |
* windows. To detect if always-on-top windows are supported by the |
|
2206 |
* current platform, use {@link Toolkit#isAlwaysOnTopSupported()} and |
|
2207 |
* {@link Window#isAlwaysOnTopSupported()}. If always-on-top mode |
|
20465
b08b3909ee92
7081584: Specification for Window.isAlwaysOnTopSupported needs to be clarified
malenkov
parents:
20454
diff
changeset
|
2208 |
* isn't supported for this window or this window's toolkit does not |
b08b3909ee92
7081584: Specification for Window.isAlwaysOnTopSupported needs to be clarified
malenkov
parents:
20454
diff
changeset
|
2209 |
* support always-on-top windows, calling this method has no effect. |
2 | 2210 |
* <p> |
2211 |
* If a SecurityManager is installed, the calling thread must be |
|
2212 |
* granted the AWTPermission "setWindowAlwaysOnTop" in |
|
2213 |
* order to set the value of this property. If this |
|
2214 |
* permission is not granted, this method will throw a |
|
2215 |
* SecurityException, and the current value of the property will |
|
2216 |
* be left unchanged. |
|
2217 |
* |
|
2218 |
* @param alwaysOnTop true if the window should always be above other |
|
2219 |
* windows |
|
2220 |
* @throws SecurityException if the calling thread does not have |
|
2221 |
* permission to set the value of always-on-top property |
|
20465
b08b3909ee92
7081584: Specification for Window.isAlwaysOnTopSupported needs to be clarified
malenkov
parents:
20454
diff
changeset
|
2222 |
* |
2 | 2223 |
* @see #isAlwaysOnTop |
2224 |
* @see #toFront |
|
2225 |
* @see #toBack |
|
2226 |
* @see AWTPermission |
|
2227 |
* @see #isAlwaysOnTopSupported |
|
20465
b08b3909ee92
7081584: Specification for Window.isAlwaysOnTopSupported needs to be clarified
malenkov
parents:
20454
diff
changeset
|
2228 |
* @see #getToolkit |
2 | 2229 |
* @see Toolkit#isAlwaysOnTopSupported |
2230 |
* @since 1.5 |
|
2231 |
*/ |
|
2232 |
public final void setAlwaysOnTop(boolean alwaysOnTop) throws SecurityException { |
|
2233 |
SecurityManager security = System.getSecurityManager(); |
|
2234 |
if (security != null) { |
|
22060
cd4f9d7dbeda
8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents:
21957
diff
changeset
|
2235 |
security.checkPermission(AWTPermissions.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION); |
2 | 2236 |
} |
2237 |
||
2238 |
boolean oldAlwaysOnTop; |
|
2239 |
synchronized(this) { |
|
2240 |
oldAlwaysOnTop = this.alwaysOnTop; |
|
2241 |
this.alwaysOnTop = alwaysOnTop; |
|
2242 |
} |
|
2243 |
if (oldAlwaysOnTop != alwaysOnTop ) { |
|
2244 |
if (isAlwaysOnTopSupported()) { |
|
2245 |
WindowPeer peer = (WindowPeer)this.peer; |
|
2246 |
synchronized(getTreeLock()) { |
|
2247 |
if (peer != null) { |
|
16892 | 2248 |
peer.updateAlwaysOnTopState(); |
2 | 2249 |
} |
2250 |
} |
|
2251 |
} |
|
2252 |
firePropertyChange("alwaysOnTop", oldAlwaysOnTop, alwaysOnTop); |
|
2253 |
} |
|
27766
e3dd9610de38
8064468: ownedWindowList access requires synchronization in Window.setAlwaysOnTop() method
alexsch
parents:
26749
diff
changeset
|
2254 |
setOwnedWindowsAlwaysOnTop(alwaysOnTop); |
e3dd9610de38
8064468: ownedWindowList access requires synchronization in Window.setAlwaysOnTop() method
alexsch
parents:
26749
diff
changeset
|
2255 |
} |
e3dd9610de38
8064468: ownedWindowList access requires synchronization in Window.setAlwaysOnTop() method
alexsch
parents:
26749
diff
changeset
|
2256 |
|
e3dd9610de38
8064468: ownedWindowList access requires synchronization in Window.setAlwaysOnTop() method
alexsch
parents:
26749
diff
changeset
|
2257 |
@SuppressWarnings({"rawtypes", "unchecked"}) |
e3dd9610de38
8064468: ownedWindowList access requires synchronization in Window.setAlwaysOnTop() method
alexsch
parents:
26749
diff
changeset
|
2258 |
private void setOwnedWindowsAlwaysOnTop(boolean alwaysOnTop) { |
e3dd9610de38
8064468: ownedWindowList access requires synchronization in Window.setAlwaysOnTop() method
alexsch
parents:
26749
diff
changeset
|
2259 |
WeakReference<Window>[] ownedWindowArray; |
e3dd9610de38
8064468: ownedWindowList access requires synchronization in Window.setAlwaysOnTop() method
alexsch
parents:
26749
diff
changeset
|
2260 |
synchronized (ownedWindowList) { |
e3dd9610de38
8064468: ownedWindowList access requires synchronization in Window.setAlwaysOnTop() method
alexsch
parents:
26749
diff
changeset
|
2261 |
ownedWindowArray = new WeakReference[ownedWindowList.size()]; |
e3dd9610de38
8064468: ownedWindowList access requires synchronization in Window.setAlwaysOnTop() method
alexsch
parents:
26749
diff
changeset
|
2262 |
ownedWindowList.copyInto(ownedWindowArray); |
e3dd9610de38
8064468: ownedWindowList access requires synchronization in Window.setAlwaysOnTop() method
alexsch
parents:
26749
diff
changeset
|
2263 |
} |
e3dd9610de38
8064468: ownedWindowList access requires synchronization in Window.setAlwaysOnTop() method
alexsch
parents:
26749
diff
changeset
|
2264 |
|
e3dd9610de38
8064468: ownedWindowList access requires synchronization in Window.setAlwaysOnTop() method
alexsch
parents:
26749
diff
changeset
|
2265 |
for (WeakReference<Window> ref : ownedWindowArray) { |
20467
c516e99769d7
7081594: Windows owned by an always-on-top window DO NOT automatically become always-on-top
alexsch
parents:
20465
diff
changeset
|
2266 |
Window window = ref.get(); |
c516e99769d7
7081594: Windows owned by an always-on-top window DO NOT automatically become always-on-top
alexsch
parents:
20465
diff
changeset
|
2267 |
if (window != null) { |
c516e99769d7
7081594: Windows owned by an always-on-top window DO NOT automatically become always-on-top
alexsch
parents:
20465
diff
changeset
|
2268 |
try { |
c516e99769d7
7081594: Windows owned by an always-on-top window DO NOT automatically become always-on-top
alexsch
parents:
20465
diff
changeset
|
2269 |
window.setAlwaysOnTop(alwaysOnTop); |
c516e99769d7
7081594: Windows owned by an always-on-top window DO NOT automatically become always-on-top
alexsch
parents:
20465
diff
changeset
|
2270 |
} catch (SecurityException ignore) { |
c516e99769d7
7081594: Windows owned by an always-on-top window DO NOT automatically become always-on-top
alexsch
parents:
20465
diff
changeset
|
2271 |
} |
c516e99769d7
7081594: Windows owned by an always-on-top window DO NOT automatically become always-on-top
alexsch
parents:
20465
diff
changeset
|
2272 |
} |
c516e99769d7
7081594: Windows owned by an always-on-top window DO NOT automatically become always-on-top
alexsch
parents:
20465
diff
changeset
|
2273 |
} |
2 | 2274 |
} |
2275 |
||
2276 |
/** |
|
2277 |
* Returns whether the always-on-top mode is supported for this |
|
2278 |
* window. Some platforms may not support always-on-top windows, some |
|
2279 |
* may support only some kinds of top-level windows; for example, |
|
2280 |
* a platform may not support always-on-top modal dialogs. |
|
20465
b08b3909ee92
7081584: Specification for Window.isAlwaysOnTopSupported needs to be clarified
malenkov
parents:
20454
diff
changeset
|
2281 |
* |
b08b3909ee92
7081584: Specification for Window.isAlwaysOnTopSupported needs to be clarified
malenkov
parents:
20454
diff
changeset
|
2282 |
* @return {@code true}, if the always-on-top mode is supported for |
b08b3909ee92
7081584: Specification for Window.isAlwaysOnTopSupported needs to be clarified
malenkov
parents:
20454
diff
changeset
|
2283 |
* this window and this window's toolkit supports always-on-top windows, |
b08b3909ee92
7081584: Specification for Window.isAlwaysOnTopSupported needs to be clarified
malenkov
parents:
20454
diff
changeset
|
2284 |
* {@code false} otherwise |
b08b3909ee92
7081584: Specification for Window.isAlwaysOnTopSupported needs to be clarified
malenkov
parents:
20454
diff
changeset
|
2285 |
* |
2 | 2286 |
* @see #setAlwaysOnTop(boolean) |
20465
b08b3909ee92
7081584: Specification for Window.isAlwaysOnTopSupported needs to be clarified
malenkov
parents:
20454
diff
changeset
|
2287 |
* @see #getToolkit |
2 | 2288 |
* @see Toolkit#isAlwaysOnTopSupported |
2289 |
* @since 1.6 |
|
2290 |
*/ |
|
2291 |
public boolean isAlwaysOnTopSupported() { |
|
2292 |
return Toolkit.getDefaultToolkit().isAlwaysOnTopSupported(); |
|
2293 |
} |
|
2294 |
||
2295 |
||
2296 |
/** |
|
2297 |
* Returns whether this window is an always-on-top window. |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2298 |
* @return {@code true}, if the window is in always-on-top state, |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2299 |
* {@code false} otherwise |
2 | 2300 |
* @see #setAlwaysOnTop |
2301 |
* @since 1.5 |
|
2302 |
*/ |
|
2303 |
public final boolean isAlwaysOnTop() { |
|
2304 |
return alwaysOnTop; |
|
2305 |
} |
|
2306 |
||
2307 |
||
2308 |
/** |
|
2309 |
* Returns the child Component of this Window that has focus if this Window |
|
2310 |
* is focused; returns null otherwise. |
|
2311 |
* |
|
2312 |
* @return the child Component with focus, or null if this Window is not |
|
2313 |
* focused |
|
2314 |
* @see #getMostRecentFocusOwner |
|
2315 |
* @see #isFocused |
|
2316 |
*/ |
|
2317 |
public Component getFocusOwner() { |
|
2318 |
return (isFocused()) |
|
2319 |
? KeyboardFocusManager.getCurrentKeyboardFocusManager(). |
|
2320 |
getFocusOwner() |
|
2321 |
: null; |
|
2322 |
} |
|
2323 |
||
2324 |
/** |
|
2325 |
* Returns the child Component of this Window that will receive the focus |
|
2326 |
* when this Window is focused. If this Window is currently focused, this |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2327 |
* method returns the same Component as {@code getFocusOwner()}. If |
2 | 2328 |
* this Window is not focused, then the child Component that most recently |
2329 |
* requested focus will be returned. If no child Component has ever |
|
2330 |
* requested focus, and this is a focusable Window, then this Window's |
|
2331 |
* initial focusable Component is returned. If no child Component has ever |
|
2332 |
* requested focus, and this is a non-focusable Window, null is returned. |
|
2333 |
* |
|
2334 |
* @return the child Component that will receive focus when this Window is |
|
2335 |
* focused |
|
2336 |
* @see #getFocusOwner |
|
2337 |
* @see #isFocused |
|
2338 |
* @see #isFocusableWindow |
|
2339 |
* @since 1.4 |
|
2340 |
*/ |
|
2341 |
public Component getMostRecentFocusOwner() { |
|
2342 |
if (isFocused()) { |
|
2343 |
return getFocusOwner(); |
|
2344 |
} else { |
|
2345 |
Component mostRecent = |
|
2346 |
KeyboardFocusManager.getMostRecentFocusOwner(this); |
|
2347 |
if (mostRecent != null) { |
|
2348 |
return mostRecent; |
|
2349 |
} else { |
|
2350 |
return (isFocusableWindow()) |
|
2351 |
? getFocusTraversalPolicy().getInitialComponent(this) |
|
2352 |
: null; |
|
2353 |
} |
|
2354 |
} |
|
2355 |
} |
|
2356 |
||
2357 |
/** |
|
2358 |
* Returns whether this Window is active. Only a Frame or a Dialog may be |
|
2359 |
* active. The native windowing system may denote the active Window or its |
|
2360 |
* children with special decorations, such as a highlighted title bar. The |
|
2361 |
* active Window is always either the focused Window, or the first Frame or |
|
2362 |
* Dialog that is an owner of the focused Window. |
|
2363 |
* |
|
2364 |
* @return whether this is the active Window. |
|
2365 |
* @see #isFocused |
|
2366 |
* @since 1.4 |
|
2367 |
*/ |
|
2368 |
public boolean isActive() { |
|
2369 |
return (KeyboardFocusManager.getCurrentKeyboardFocusManager(). |
|
2370 |
getActiveWindow() == this); |
|
2371 |
} |
|
2372 |
||
2373 |
/** |
|
2374 |
* Returns whether this Window is focused. If there exists a focus owner, |
|
2375 |
* the focused Window is the Window that is, or contains, that focus owner. |
|
2376 |
* If there is no focus owner, then no Window is focused. |
|
2377 |
* <p> |
|
2378 |
* If the focused Window is a Frame or a Dialog it is also the active |
|
2379 |
* Window. Otherwise, the active Window is the first Frame or Dialog that |
|
2380 |
* is an owner of the focused Window. |
|
2381 |
* |
|
2382 |
* @return whether this is the focused Window. |
|
2383 |
* @see #isActive |
|
2384 |
* @since 1.4 |
|
2385 |
*/ |
|
2386 |
public boolean isFocused() { |
|
2387 |
return (KeyboardFocusManager.getCurrentKeyboardFocusManager(). |
|
2388 |
getGlobalFocusedWindow() == this); |
|
2389 |
} |
|
2390 |
||
2391 |
/** |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2392 |
* Gets a focus traversal key for this Window. (See {@code |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2393 |
* setFocusTraversalKeys} for a full description of each key.) |
2 | 2394 |
* <p> |
2395 |
* If the traversal key has not been explicitly set for this Window, |
|
2396 |
* then this Window's parent's traversal key is returned. If the |
|
2397 |
* traversal key has not been explicitly set for any of this Window's |
|
2398 |
* ancestors, then the current KeyboardFocusManager's default traversal key |
|
2399 |
* is returned. |
|
2400 |
* |
|
2401 |
* @param id one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, |
|
2402 |
* KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, |
|
2403 |
* KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or |
|
2404 |
* KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS |
|
2405 |
* @return the AWTKeyStroke for the specified key |
|
2406 |
* @see Container#setFocusTraversalKeys |
|
2407 |
* @see KeyboardFocusManager#FORWARD_TRAVERSAL_KEYS |
|
2408 |
* @see KeyboardFocusManager#BACKWARD_TRAVERSAL_KEYS |
|
2409 |
* @see KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS |
|
2410 |
* @see KeyboardFocusManager#DOWN_CYCLE_TRAVERSAL_KEYS |
|
2411 |
* @throws IllegalArgumentException if id is not one of |
|
2412 |
* KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, |
|
2413 |
* KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, |
|
2414 |
* KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or |
|
2415 |
* KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS |
|
2416 |
* @since 1.4 |
|
2417 |
*/ |
|
15318
607db339afcc
8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents:
12661
diff
changeset
|
2418 |
@SuppressWarnings("unchecked") |
2 | 2419 |
public Set<AWTKeyStroke> getFocusTraversalKeys(int id) { |
2420 |
if (id < 0 || id >= KeyboardFocusManager.TRAVERSAL_KEY_LENGTH) { |
|
2421 |
throw new IllegalArgumentException("invalid focus traversal key identifier"); |
|
2422 |
} |
|
2423 |
||
2424 |
// Okay to return Set directly because it is an unmodifiable view |
|
15318
607db339afcc
8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents:
12661
diff
changeset
|
2425 |
@SuppressWarnings("rawtypes") |
2 | 2426 |
Set keystrokes = (focusTraversalKeys != null) |
2427 |
? focusTraversalKeys[id] |
|
2428 |
: null; |
|
2429 |
||
2430 |
if (keystrokes != null) { |
|
2431 |
return keystrokes; |
|
2432 |
} else { |
|
2433 |
return KeyboardFocusManager.getCurrentKeyboardFocusManager(). |
|
2434 |
getDefaultFocusTraversalKeys(id); |
|
2435 |
} |
|
2436 |
} |
|
2437 |
||
2438 |
/** |
|
2439 |
* Does nothing because Windows must always be roots of a focus traversal |
|
2440 |
* cycle. The passed-in value is ignored. |
|
2441 |
* |
|
2442 |
* @param focusCycleRoot this value is ignored |
|
2443 |
* @see #isFocusCycleRoot |
|
2444 |
* @see Container#setFocusTraversalPolicy |
|
2445 |
* @see Container#getFocusTraversalPolicy |
|
2446 |
* @since 1.4 |
|
2447 |
*/ |
|
2448 |
public final void setFocusCycleRoot(boolean focusCycleRoot) { |
|
2449 |
} |
|
2450 |
||
2451 |
/** |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2452 |
* Always returns {@code true} because all Windows must be roots of a |
2 | 2453 |
* focus traversal cycle. |
2454 |
* |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2455 |
* @return {@code true} |
2 | 2456 |
* @see #setFocusCycleRoot |
2457 |
* @see Container#setFocusTraversalPolicy |
|
2458 |
* @see Container#getFocusTraversalPolicy |
|
2459 |
* @since 1.4 |
|
2460 |
*/ |
|
2461 |
public final boolean isFocusCycleRoot() { |
|
2462 |
return true; |
|
2463 |
} |
|
2464 |
||
2465 |
/** |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2466 |
* Always returns {@code null} because Windows have no ancestors; they |
2 | 2467 |
* represent the top of the Component hierarchy. |
2468 |
* |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2469 |
* @return {@code null} |
2 | 2470 |
* @see Container#isFocusCycleRoot() |
2471 |
* @since 1.4 |
|
2472 |
*/ |
|
2473 |
public final Container getFocusCycleRootAncestor() { |
|
2474 |
return null; |
|
2475 |
} |
|
2476 |
||
2477 |
/** |
|
2478 |
* Returns whether this Window can become the focused Window, that is, |
|
2479 |
* whether this Window or any of its subcomponents can become the focus |
|
2480 |
* owner. For a Frame or Dialog to be focusable, its focusable Window state |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2481 |
* must be set to {@code true}. For a Window which is not a Frame or |
2 | 2482 |
* Dialog to be focusable, its focusable Window state must be set to |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2483 |
* {@code true}, its nearest owning Frame or Dialog must be |
2 | 2484 |
* showing on the screen, and it must contain at least one Component in |
2485 |
* its focus traversal cycle. If any of these conditions is not met, then |
|
2486 |
* neither this Window nor any of its subcomponents can become the focus |
|
2487 |
* owner. |
|
2488 |
* |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2489 |
* @return {@code true} if this Window can be the focused Window; |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2490 |
* {@code false} otherwise |
2 | 2491 |
* @see #getFocusableWindowState |
2492 |
* @see #setFocusableWindowState |
|
2493 |
* @see #isShowing |
|
2494 |
* @see Component#isFocusable |
|
2495 |
* @since 1.4 |
|
2496 |
*/ |
|
2497 |
public final boolean isFocusableWindow() { |
|
2498 |
// If a Window/Frame/Dialog was made non-focusable, then it is always |
|
2499 |
// non-focusable. |
|
2500 |
if (!getFocusableWindowState()) { |
|
2501 |
return false; |
|
2502 |
} |
|
2503 |
||
2504 |
// All other tests apply only to Windows. |
|
2505 |
if (this instanceof Frame || this instanceof Dialog) { |
|
2506 |
return true; |
|
2507 |
} |
|
2508 |
||
2509 |
// A Window must have at least one Component in its root focus |
|
2510 |
// traversal cycle to be focusable. |
|
2511 |
if (getFocusTraversalPolicy().getDefaultComponent(this) == null) { |
|
2512 |
return false; |
|
2513 |
} |
|
2514 |
||
2515 |
// A Window's nearest owning Frame or Dialog must be showing on the |
|
2516 |
// screen. |
|
2517 |
for (Window owner = getOwner(); owner != null; |
|
2518 |
owner = owner.getOwner()) |
|
2519 |
{ |
|
2520 |
if (owner instanceof Frame || owner instanceof Dialog) { |
|
2521 |
return owner.isShowing(); |
|
2522 |
} |
|
2523 |
} |
|
2524 |
||
2525 |
return false; |
|
2526 |
} |
|
2527 |
||
2528 |
/** |
|
2529 |
* Returns whether this Window can become the focused Window if it meets |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2530 |
* the other requirements outlined in {@code isFocusableWindow}. If |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2531 |
* this method returns {@code false}, then |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2532 |
* {@code isFocusableWindow} will return {@code false} as well. |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2533 |
* If this method returns {@code true}, then |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2534 |
* {@code isFocusableWindow} may return {@code true} or |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2535 |
* {@code false} depending upon the other requirements which must be |
2 | 2536 |
* met in order for a Window to be focusable. |
2537 |
* <p> |
|
2538 |
* By default, all Windows have a focusable Window state of |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2539 |
* {@code true}. |
2 | 2540 |
* |
2541 |
* @return whether this Window can be the focused Window |
|
2542 |
* @see #isFocusableWindow |
|
2543 |
* @see #setFocusableWindowState |
|
2544 |
* @see #isShowing |
|
2545 |
* @see Component#setFocusable |
|
2546 |
* @since 1.4 |
|
2547 |
*/ |
|
2548 |
public boolean getFocusableWindowState() { |
|
2549 |
return focusableWindowState; |
|
2550 |
} |
|
2551 |
||
2552 |
/** |
|
2553 |
* Sets whether this Window can become the focused Window if it meets |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2554 |
* the other requirements outlined in {@code isFocusableWindow}. If |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2555 |
* this Window's focusable Window state is set to {@code false}, then |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2556 |
* {@code isFocusableWindow} will return {@code false}. If this |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2557 |
* Window's focusable Window state is set to {@code true}, then |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2558 |
* {@code isFocusableWindow} may return {@code true} or |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2559 |
* {@code false} depending upon the other requirements which must be |
2 | 2560 |
* met in order for a Window to be focusable. |
2561 |
* <p> |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2562 |
* Setting a Window's focusability state to {@code false} is the |
2 | 2563 |
* standard mechanism for an application to identify to the AWT a Window |
2564 |
* which will be used as a floating palette or toolbar, and thus should be |
|
2565 |
* a non-focusable Window. |
|
2566 |
* |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2567 |
* Setting the focusability state on a visible {@code Window} |
23717 | 2568 |
* can have a delayed effect on some platforms — the actual |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2569 |
* change may happen only when the {@code Window} becomes |
2 | 2570 |
* hidden and then visible again. To ensure consistent behavior |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2571 |
* across platforms, set the {@code Window}'s focusable state |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2572 |
* when the {@code Window} is invisible and then show it. |
2 | 2573 |
* |
2574 |
* @param focusableWindowState whether this Window can be the focused |
|
2575 |
* Window |
|
2576 |
* @see #isFocusableWindow |
|
2577 |
* @see #getFocusableWindowState |
|
2578 |
* @see #isShowing |
|
2579 |
* @see Component#setFocusable |
|
2580 |
* @since 1.4 |
|
2581 |
*/ |
|
2582 |
public void setFocusableWindowState(boolean focusableWindowState) { |
|
2583 |
boolean oldFocusableWindowState; |
|
2584 |
synchronized (this) { |
|
2585 |
oldFocusableWindowState = this.focusableWindowState; |
|
2586 |
this.focusableWindowState = focusableWindowState; |
|
2587 |
} |
|
2588 |
WindowPeer peer = (WindowPeer)this.peer; |
|
2589 |
if (peer != null) { |
|
2590 |
peer.updateFocusableWindowState(); |
|
2591 |
} |
|
2592 |
firePropertyChange("focusableWindowState", oldFocusableWindowState, |
|
2593 |
focusableWindowState); |
|
2594 |
if (oldFocusableWindowState && !focusableWindowState && isFocused()) { |
|
2595 |
for (Window owner = getOwner(); |
|
2596 |
owner != null; |
|
2597 |
owner = owner.getOwner()) |
|
2598 |
{ |
|
2599 |
Component toFocus = |
|
2600 |
KeyboardFocusManager.getMostRecentFocusOwner(owner); |
|
37694
c064aefc5a2f
8080395: consider making sun.awt.CausedFocusEvent functionality public
ssadetsky
parents:
36511
diff
changeset
|
2601 |
if (toFocus != null && toFocus.requestFocus(false, FocusEvent.Cause.ACTIVATION)) { |
2 | 2602 |
return; |
2603 |
} |
|
2604 |
} |
|
2605 |
KeyboardFocusManager.getCurrentKeyboardFocusManager(). |
|
12651
8c69dd24bf07
7110683: Issues with some KeyboardFocusManager method
ant
parents:
11982
diff
changeset
|
2606 |
clearGlobalFocusOwnerPriv(); |
2 | 2607 |
} |
2608 |
} |
|
2609 |
||
2610 |
/** |
|
2611 |
* Sets whether this window should receive focus on |
|
2612 |
* subsequently being shown (with a call to {@link #setVisible setVisible(true)}), |
|
2613 |
* or being moved to the front (with a call to {@link #toFront}). |
|
2614 |
* <p> |
|
2615 |
* Note that {@link #setVisible setVisible(true)} may be called indirectly |
|
2616 |
* (e.g. when showing an owner of the window makes the window to be shown). |
|
2617 |
* {@link #toFront} may also be called indirectly (e.g. when |
|
2618 |
* {@link #setVisible setVisible(true)} is called on already visible window). |
|
2619 |
* In all such cases this property takes effect as well. |
|
2620 |
* <p> |
|
2621 |
* The value of the property is not inherited by owned windows. |
|
2622 |
* |
|
2623 |
* @param autoRequestFocus whether this window should be focused on |
|
2624 |
* subsequently being shown or being moved to the front |
|
2625 |
* @see #isAutoRequestFocus |
|
2626 |
* @see #isFocusableWindow |
|
2627 |
* @see #setVisible |
|
2628 |
* @see #toFront |
|
2629 |
* @since 1.7 |
|
2630 |
*/ |
|
2631 |
public void setAutoRequestFocus(boolean autoRequestFocus) { |
|
2632 |
this.autoRequestFocus = autoRequestFocus; |
|
2633 |
} |
|
2634 |
||
2635 |
/** |
|
2636 |
* Returns whether this window should receive focus on subsequently being shown |
|
2637 |
* (with a call to {@link #setVisible setVisible(true)}), or being moved to the front |
|
2638 |
* (with a call to {@link #toFront}). |
|
2639 |
* <p> |
|
2640 |
* By default, the window has {@code autoRequestFocus} value of {@code true}. |
|
2641 |
* |
|
2642 |
* @return {@code autoRequestFocus} value |
|
2643 |
* @see #setAutoRequestFocus |
|
2644 |
* @since 1.7 |
|
2645 |
*/ |
|
2646 |
public boolean isAutoRequestFocus() { |
|
2647 |
return autoRequestFocus; |
|
2648 |
} |
|
2649 |
||
2650 |
/** |
|
2651 |
* Adds a PropertyChangeListener to the listener list. The listener is |
|
2652 |
* registered for all bound properties of this class, including the |
|
2653 |
* following: |
|
2654 |
* <ul> |
|
2655 |
* <li>this Window's font ("font")</li> |
|
2656 |
* <li>this Window's background color ("background")</li> |
|
2657 |
* <li>this Window's foreground color ("foreground")</li> |
|
2658 |
* <li>this Window's focusability ("focusable")</li> |
|
2659 |
* <li>this Window's focus traversal keys enabled state |
|
2660 |
* ("focusTraversalKeysEnabled")</li> |
|
2661 |
* <li>this Window's Set of FORWARD_TRAVERSAL_KEYS |
|
2662 |
* ("forwardFocusTraversalKeys")</li> |
|
2663 |
* <li>this Window's Set of BACKWARD_TRAVERSAL_KEYS |
|
2664 |
* ("backwardFocusTraversalKeys")</li> |
|
2665 |
* <li>this Window's Set of UP_CYCLE_TRAVERSAL_KEYS |
|
2666 |
* ("upCycleFocusTraversalKeys")</li> |
|
2667 |
* <li>this Window's Set of DOWN_CYCLE_TRAVERSAL_KEYS |
|
2668 |
* ("downCycleFocusTraversalKeys")</li> |
|
2669 |
* <li>this Window's focus traversal policy ("focusTraversalPolicy") |
|
2670 |
* </li> |
|
2671 |
* <li>this Window's focusable Window state ("focusableWindowState") |
|
2672 |
* </li> |
|
2673 |
* <li>this Window's always-on-top state("alwaysOnTop")</li> |
|
2674 |
* </ul> |
|
2675 |
* Note that if this Window is inheriting a bound property, then no |
|
2676 |
* event will be fired in response to a change in the inherited property. |
|
2677 |
* <p> |
|
2678 |
* If listener is null, no exception is thrown and no action is performed. |
|
2679 |
* |
|
2680 |
* @param listener the PropertyChangeListener to be added |
|
2681 |
* |
|
2682 |
* @see Component#removePropertyChangeListener |
|
2683 |
* @see #addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener) |
|
2684 |
*/ |
|
2685 |
public void addPropertyChangeListener(PropertyChangeListener listener) { |
|
2686 |
super.addPropertyChangeListener(listener); |
|
2687 |
} |
|
2688 |
||
2689 |
/** |
|
2690 |
* Adds a PropertyChangeListener to the listener list for a specific |
|
2691 |
* property. The specified property may be user-defined, or one of the |
|
2692 |
* following: |
|
2693 |
* <ul> |
|
2694 |
* <li>this Window's font ("font")</li> |
|
2695 |
* <li>this Window's background color ("background")</li> |
|
2696 |
* <li>this Window's foreground color ("foreground")</li> |
|
2697 |
* <li>this Window's focusability ("focusable")</li> |
|
2698 |
* <li>this Window's focus traversal keys enabled state |
|
2699 |
* ("focusTraversalKeysEnabled")</li> |
|
2700 |
* <li>this Window's Set of FORWARD_TRAVERSAL_KEYS |
|
2701 |
* ("forwardFocusTraversalKeys")</li> |
|
2702 |
* <li>this Window's Set of BACKWARD_TRAVERSAL_KEYS |
|
2703 |
* ("backwardFocusTraversalKeys")</li> |
|
2704 |
* <li>this Window's Set of UP_CYCLE_TRAVERSAL_KEYS |
|
2705 |
* ("upCycleFocusTraversalKeys")</li> |
|
2706 |
* <li>this Window's Set of DOWN_CYCLE_TRAVERSAL_KEYS |
|
2707 |
* ("downCycleFocusTraversalKeys")</li> |
|
2708 |
* <li>this Window's focus traversal policy ("focusTraversalPolicy") |
|
2709 |
* </li> |
|
2710 |
* <li>this Window's focusable Window state ("focusableWindowState") |
|
2711 |
* </li> |
|
2712 |
* <li>this Window's always-on-top state("alwaysOnTop")</li> |
|
2713 |
* </ul> |
|
2714 |
* Note that if this Window is inheriting a bound property, then no |
|
2715 |
* event will be fired in response to a change in the inherited property. |
|
2716 |
* <p> |
|
2717 |
* If listener is null, no exception is thrown and no action is performed. |
|
2718 |
* |
|
2719 |
* @param propertyName one of the property names listed above |
|
2720 |
* @param listener the PropertyChangeListener to be added |
|
2721 |
* |
|
2722 |
* @see #addPropertyChangeListener(java.beans.PropertyChangeListener) |
|
2723 |
* @see Component#removePropertyChangeListener |
|
2724 |
*/ |
|
2725 |
public void addPropertyChangeListener(String propertyName, |
|
2726 |
PropertyChangeListener listener) { |
|
2727 |
super.addPropertyChangeListener(propertyName, listener); |
|
2728 |
} |
|
2729 |
||
2730 |
/** |
|
4261 | 2731 |
* Indicates if this container is a validate root. |
2732 |
* <p> |
|
2733 |
* {@code Window} objects are the validate roots, and, therefore, they |
|
2734 |
* override this method to return {@code true}. |
|
2735 |
* |
|
2736 |
* @return {@code true} |
|
2737 |
* @since 1.7 |
|
2738 |
* @see java.awt.Container#isValidateRoot |
|
2739 |
*/ |
|
2740 |
@Override |
|
2741 |
public boolean isValidateRoot() { |
|
2742 |
return true; |
|
2743 |
} |
|
2744 |
||
2745 |
/** |
|
2 | 2746 |
* Dispatches an event to this window or one of its sub components. |
2747 |
* @param e the event |
|
2748 |
*/ |
|
2749 |
void dispatchEventImpl(AWTEvent e) { |
|
2750 |
if (e.getID() == ComponentEvent.COMPONENT_RESIZED) { |
|
2751 |
invalidate(); |
|
2752 |
validate(); |
|
2753 |
} |
|
2754 |
super.dispatchEventImpl(e); |
|
2755 |
} |
|
2756 |
||
2757 |
/** |
|
2758 |
* @deprecated As of JDK version 1.1 |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2759 |
* replaced by {@code dispatchEvent(AWTEvent)}. |
2 | 2760 |
*/ |
2761 |
@Deprecated |
|
2762 |
public boolean postEvent(Event e) { |
|
2763 |
if (handleEvent(e)) { |
|
2764 |
e.consume(); |
|
2765 |
return true; |
|
2766 |
} |
|
2767 |
return false; |
|
2768 |
} |
|
2769 |
||
2770 |
/** |
|
2771 |
* Checks if this Window is showing on screen. |
|
2772 |
* @see Component#setVisible |
|
2773 |
*/ |
|
2774 |
public boolean isShowing() { |
|
2775 |
return visible; |
|
2776 |
} |
|
2777 |
||
11982
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
2778 |
boolean isDisposing() { |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
2779 |
return disposing; |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
2780 |
} |
9e19ca1ff707
7145980: Dispose method of window.java takes long
bagiras
parents:
11813
diff
changeset
|
2781 |
|
2 | 2782 |
/** |
2783 |
* @deprecated As of J2SE 1.4, replaced by |
|
2784 |
* {@link Component#applyComponentOrientation Component.applyComponentOrientation}. |
|
29886 | 2785 |
* @param rb the resource bundle |
2 | 2786 |
*/ |
2787 |
@Deprecated |
|
2788 |
public void applyResourceBundle(ResourceBundle rb) { |
|
2789 |
applyComponentOrientation(ComponentOrientation.getOrientation(rb)); |
|
2790 |
} |
|
2791 |
||
2792 |
/** |
|
2793 |
* @deprecated As of J2SE 1.4, replaced by |
|
2794 |
* {@link Component#applyComponentOrientation Component.applyComponentOrientation}. |
|
29886 | 2795 |
* @param rbName the resource name |
2 | 2796 |
*/ |
2797 |
@Deprecated |
|
2798 |
public void applyResourceBundle(String rbName) { |
|
36511 | 2799 |
// Use the unnamed module from the TCCL or system class loader. |
2800 |
ClassLoader cl = Thread.currentThread().getContextClassLoader(); |
|
2801 |
if (cl == null) { |
|
2802 |
cl = ClassLoader.getSystemClassLoader(); |
|
2803 |
} |
|
2804 |
applyResourceBundle(ResourceBundle.getBundle(rbName, cl.getUnnamedModule())); |
|
2 | 2805 |
} |
2806 |
||
2807 |
/* |
|
2808 |
* Support for tracking all windows owned by this window |
|
2809 |
*/ |
|
15318
607db339afcc
8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents:
12661
diff
changeset
|
2810 |
void addOwnedWindow(WeakReference<Window> weakWindow) { |
2 | 2811 |
if (weakWindow != null) { |
2812 |
synchronized(ownedWindowList) { |
|
2813 |
// this if statement should really be an assert, but we don't |
|
2814 |
// have asserts... |
|
2815 |
if (!ownedWindowList.contains(weakWindow)) { |
|
2816 |
ownedWindowList.addElement(weakWindow); |
|
2817 |
} |
|
2818 |
} |
|
2819 |
} |
|
2820 |
} |
|
2821 |
||
15318
607db339afcc
8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents:
12661
diff
changeset
|
2822 |
void removeOwnedWindow(WeakReference<Window> weakWindow) { |
2 | 2823 |
if (weakWindow != null) { |
2824 |
// synchronized block not required since removeElement is |
|
2825 |
// already synchronized |
|
2826 |
ownedWindowList.removeElement(weakWindow); |
|
2827 |
} |
|
2828 |
} |
|
2829 |
||
2830 |
void connectOwnedWindow(Window child) { |
|
2831 |
child.parent = this; |
|
2832 |
addOwnedWindow(child.weakThis); |
|
20450 | 2833 |
child.disposerRecord.updateOwner(); |
2 | 2834 |
} |
2835 |
||
2836 |
private void addToWindowList() { |
|
2837 |
synchronized (Window.class) { |
|
15318
607db339afcc
8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents:
12661
diff
changeset
|
2838 |
@SuppressWarnings("unchecked") |
2 | 2839 |
Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>)appContext.get(Window.class); |
2840 |
if (windowList == null) { |
|
2841 |
windowList = new Vector<WeakReference<Window>>(); |
|
2842 |
appContext.put(Window.class, windowList); |
|
2843 |
} |
|
2844 |
windowList.add(weakThis); |
|
2845 |
} |
|
2846 |
} |
|
2847 |
||
15318
607db339afcc
8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents:
12661
diff
changeset
|
2848 |
private static void removeFromWindowList(AppContext context, WeakReference<Window> weakThis) { |
2 | 2849 |
synchronized (Window.class) { |
15318
607db339afcc
8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents:
12661
diff
changeset
|
2850 |
@SuppressWarnings("unchecked") |
2 | 2851 |
Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>)context.get(Window.class); |
2852 |
if (windowList != null) { |
|
2853 |
windowList.remove(weakThis); |
|
2854 |
} |
|
2855 |
} |
|
2856 |
} |
|
2857 |
||
2858 |
private void removeFromWindowList() { |
|
2859 |
removeFromWindowList(appContext, weakThis); |
|
2860 |
} |
|
2861 |
||
2862 |
/** |
|
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2863 |
* Window type. |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2864 |
* |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2865 |
* Synchronization: ObjectLock |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2866 |
*/ |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2867 |
private Type type = Type.NORMAL; |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2868 |
|
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2869 |
/** |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2870 |
* Sets the type of the window. |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2871 |
* |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2872 |
* This method can only be called while the window is not displayable. |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2873 |
* |
25162 | 2874 |
* @param type the window type |
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2875 |
* @throws IllegalComponentStateException if the window |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2876 |
* is displayable. |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2877 |
* @throws IllegalArgumentException if the type is {@code null} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2878 |
* @see Component#isDisplayable |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2879 |
* @see #getType |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2880 |
* @since 1.7 |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2881 |
*/ |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2882 |
public void setType(Type type) { |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2883 |
if (type == null) { |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2884 |
throw new IllegalArgumentException("type should not be null."); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2885 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2886 |
synchronized (getTreeLock()) { |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2887 |
if (isDisplayable()) { |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2888 |
throw new IllegalComponentStateException( |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2889 |
"The window is displayable."); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2890 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2891 |
synchronized (getObjectLock()) { |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2892 |
this.type = type; |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2893 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2894 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2895 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2896 |
|
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2897 |
/** |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2898 |
* Returns the type of the window. |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2899 |
* |
25162 | 2900 |
* @return the type of the window |
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2901 |
* @see #setType |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2902 |
* @since 1.7 |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2903 |
*/ |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2904 |
public Type getType() { |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2905 |
synchronized (getObjectLock()) { |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2906 |
return type; |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2907 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2908 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2909 |
|
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4261
diff
changeset
|
2910 |
/** |
2 | 2911 |
* The window serialized data version. |
2912 |
* |
|
2913 |
* @serial |
|
2914 |
*/ |
|
2915 |
private int windowSerializedDataVersion = 2; |
|
2916 |
||
2917 |
/** |
|
2918 |
* Writes default serializable fields to stream. Writes |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2919 |
* a list of serializable {@code WindowListener}s and |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2920 |
* {@code WindowFocusListener}s as optional data. |
2 | 2921 |
* Writes a list of child windows as optional data. |
2922 |
* Writes a list of icon images as optional data |
|
2923 |
* |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2924 |
* @param s the {@code ObjectOutputStream} to write |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2925 |
* @serialData {@code null} terminated sequence of |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2926 |
* 0 or more pairs; the pair consists of a {@code String} |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2927 |
* and {@code Object}; the {@code String} |
2 | 2928 |
* indicates the type of object and is one of the following: |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2929 |
* {@code windowListenerK} indicating a |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2930 |
* {@code WindowListener} object; |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2931 |
* {@code windowFocusWindowK} indicating a |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2932 |
* {@code WindowFocusListener} object; |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2933 |
* {@code ownedWindowK} indicating a child |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
2934 |
* {@code Window} object |
2 | 2935 |
* |
2936 |
* @see AWTEventMulticaster#save(java.io.ObjectOutputStream, java.lang.String, java.util.EventListener) |
|
2937 |
* @see Component#windowListenerK |
|
2938 |
* @see Component#windowFocusListenerK |
|
2939 |
* @see Component#ownedWindowK |
|
2940 |
* @see #readObject(ObjectInputStream) |
|
2941 |
*/ |
|
2942 |
private void writeObject(ObjectOutputStream s) throws IOException { |
|
2943 |
synchronized (this) { |
|
2944 |
// Update old focusMgr fields so that our object stream can be read |
|
2945 |
// by previous releases |
|
2946 |
focusMgr = new FocusManager(); |
|
2947 |
focusMgr.focusRoot = this; |
|
2948 |
focusMgr.focusOwner = getMostRecentFocusOwner(); |
|
2949 |
||
2950 |
s.defaultWriteObject(); |
|
2951 |
||
2952 |
// Clear fields so that we don't keep extra references around |
|
2953 |
focusMgr = null; |
|
2954 |
||
2955 |
AWTEventMulticaster.save(s, windowListenerK, windowListener); |
|
2956 |
AWTEventMulticaster.save(s, windowFocusListenerK, windowFocusListener); |
|
2957 |
AWTEventMulticaster.save(s, windowStateListenerK, windowStateListener); |
|
2958 |
} |
|
2959 |
||
2960 |
s.writeObject(null); |
|
2961 |
||
2962 |
synchronized (ownedWindowList) { |
|
2963 |
for (int i = 0; i < ownedWindowList.size(); i++) { |
|
2964 |
Window child = ownedWindowList.elementAt(i).get(); |
|
2965 |
if (child != null) { |
|
2966 |
s.writeObject(ownedWindowK); |
|
2967 |
s.writeObject(child); |
|
2968 |
} |
|
2969 |
} |
|
2970 |
} |
|
2971 |
s.writeObject(null); |
|
2972 |
||
2973 |
//write icon array |
|
2974 |
if (icons != null) { |
|
2975 |
for (Image i : icons) { |
|
2976 |
if (i instanceof Serializable) { |
|
2977 |
s.writeObject(i); |
|
2978 |
} |
|
2979 |
} |
|
2980 |
} |
|
2981 |
s.writeObject(null); |
|
2982 |
} |
|
2983 |
||
2984 |
// |
|
2985 |
// Part of deserialization procedure to be called before |
|
2986 |
// user's code. |
|
2987 |
// |
|
2988 |
private void initDeserializedWindow() { |
|
2989 |
setWarningString(); |
|
2990 |
inputContextLock = new Object(); |
|
2991 |
||
2992 |
// Deserialized Windows are not yet visible. |
|
2993 |
visible = false; |
|
2994 |
||
15318
607db339afcc
8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents:
12661
diff
changeset
|
2995 |
weakThis = new WeakReference<>(this); |
2 | 2996 |
|
2997 |
anchor = new Object(); |
|
20450 | 2998 |
disposerRecord = new WindowDisposerRecord(appContext, this); |
2999 |
sun.java2d.Disposer.addRecord(anchor, disposerRecord); |
|
2 | 3000 |
|
3001 |
addToWindowList(); |
|
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
3002 |
initGC(null); |
21281
061c0ee6607c
8027152: Regression: test closed/java/awt/Serialize/NullSerializationTest/NullSerializationTest.html fails since JDK 8 b112
pchelko
parents:
21278
diff
changeset
|
3003 |
ownedWindowList = new Vector<>(); |
2 | 3004 |
} |
3005 |
||
3006 |
private void deserializeResources(ObjectInputStream s) |
|
3007 |
throws ClassNotFoundException, IOException, HeadlessException { |
|
3008 |
||
3009 |
if (windowSerializedDataVersion < 2) { |
|
3010 |
// Translate old-style focus tracking to new model. For 1.4 and |
|
3011 |
// later releases, we'll rely on the Window's initial focusable |
|
3012 |
// Component. |
|
3013 |
if (focusMgr != null) { |
|
3014 |
if (focusMgr.focusOwner != null) { |
|
3015 |
KeyboardFocusManager. |
|
3016 |
setMostRecentFocusOwner(this, focusMgr.focusOwner); |
|
3017 |
} |
|
3018 |
} |
|
3019 |
||
3020 |
// This field is non-transient and relies on default serialization. |
|
3021 |
// However, the default value is insufficient, so we need to set |
|
3022 |
// it explicitly for object data streams prior to 1.4. |
|
3023 |
focusableWindowState = true; |
|
3024 |
||
3025 |
||
3026 |
} |
|
3027 |
||
3028 |
Object keyOrNull; |
|
3029 |
while(null != (keyOrNull = s.readObject())) { |
|
3030 |
String key = ((String)keyOrNull).intern(); |
|
3031 |
||
3032 |
if (windowListenerK == key) { |
|
3033 |
addWindowListener((WindowListener)(s.readObject())); |
|
3034 |
} else if (windowFocusListenerK == key) { |
|
3035 |
addWindowFocusListener((WindowFocusListener)(s.readObject())); |
|
3036 |
} else if (windowStateListenerK == key) { |
|
3037 |
addWindowStateListener((WindowStateListener)(s.readObject())); |
|
3038 |
} else // skip value for unrecognized key |
|
3039 |
s.readObject(); |
|
3040 |
} |
|
3041 |
||
3042 |
try { |
|
3043 |
while (null != (keyOrNull = s.readObject())) { |
|
3044 |
String key = ((String)keyOrNull).intern(); |
|
3045 |
||
3046 |
if (ownedWindowK == key) |
|
3047 |
connectOwnedWindow((Window) s.readObject()); |
|
3048 |
||
3049 |
else // skip value for unrecognized key |
|
3050 |
s.readObject(); |
|
3051 |
} |
|
3052 |
||
3053 |
//read icons |
|
3054 |
Object obj = s.readObject(); //Throws OptionalDataException |
|
3055 |
//for pre1.6 objects. |
|
3056 |
icons = new ArrayList<Image>(); //Frame.readObject() assumes |
|
3057 |
//pre1.6 version if icons is null. |
|
3058 |
while (obj != null) { |
|
3059 |
if (obj instanceof Image) { |
|
3060 |
icons.add((Image)obj); |
|
3061 |
} |
|
3062 |
obj = s.readObject(); |
|
3063 |
} |
|
3064 |
} |
|
3065 |
catch (OptionalDataException e) { |
|
3066 |
// 1.1 serialized form |
|
3067 |
// ownedWindowList will be updated by Frame.readObject |
|
3068 |
} |
|
3069 |
||
3070 |
} |
|
3071 |
||
3072 |
/** |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3073 |
* Reads the {@code ObjectInputStream} and an optional |
2 | 3074 |
* list of listeners to receive various events fired by |
3075 |
* the component; also reads a list of |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3076 |
* (possibly {@code null}) child windows. |
2 | 3077 |
* Unrecognized keys or values will be ignored. |
3078 |
* |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3079 |
* @param s the {@code ObjectInputStream} to read |
2 | 3080 |
* @exception HeadlessException if |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3081 |
* {@code GraphicsEnvironment.isHeadless} returns |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3082 |
* {@code true} |
2 | 3083 |
* @see java.awt.GraphicsEnvironment#isHeadless |
3084 |
* @see #writeObject |
|
3085 |
*/ |
|
3086 |
private void readObject(ObjectInputStream s) |
|
3087 |
throws ClassNotFoundException, IOException, HeadlessException |
|
3088 |
{ |
|
3089 |
GraphicsEnvironment.checkHeadless(); |
|
3090 |
initDeserializedWindow(); |
|
3091 |
ObjectInputStream.GetField f = s.readFields(); |
|
3092 |
||
3093 |
syncLWRequests = f.get("syncLWRequests", systemSyncLWRequests); |
|
3094 |
state = f.get("state", 0); |
|
3095 |
focusableWindowState = f.get("focusableWindowState", true); |
|
3096 |
windowSerializedDataVersion = f.get("windowSerializedDataVersion", 1); |
|
3097 |
locationByPlatform = f.get("locationByPlatform", locationByPlatformProp); |
|
3098 |
// Note: 1.4 (or later) doesn't use focusMgr |
|
3099 |
focusMgr = (FocusManager)f.get("focusMgr", null); |
|
3100 |
Dialog.ModalExclusionType et = (Dialog.ModalExclusionType) |
|
3101 |
f.get("modalExclusionType", Dialog.ModalExclusionType.NO_EXCLUDE); |
|
3102 |
setModalExclusionType(et); // since 6.0 |
|
3103 |
boolean aot = f.get("alwaysOnTop", false); |
|
3104 |
if(aot) { |
|
3105 |
setAlwaysOnTop(aot); // since 1.5; subject to permission check |
|
3106 |
} |
|
2451 | 3107 |
shape = (Shape)f.get("shape", null); |
3108 |
opacity = (Float)f.get("opacity", 1.0f); |
|
2 | 3109 |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
3110 |
this.securityWarningWidth = 0; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
3111 |
this.securityWarningHeight = 0; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
3112 |
this.securityWarningPointX = 2.0; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
3113 |
this.securityWarningPointY = 0.0; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
3114 |
this.securityWarningAlignmentX = RIGHT_ALIGNMENT; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
3115 |
this.securityWarningAlignmentY = TOP_ALIGNMENT; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
3116 |
|
2 | 3117 |
deserializeResources(s); |
3118 |
} |
|
3119 |
||
3120 |
/* |
|
3121 |
* --- Accessibility Support --- |
|
3122 |
* |
|
3123 |
*/ |
|
3124 |
||
3125 |
/** |
|
3126 |
* Gets the AccessibleContext associated with this Window. |
|
3127 |
* For windows, the AccessibleContext takes the form of an |
|
3128 |
* AccessibleAWTWindow. |
|
3129 |
* A new AccessibleAWTWindow instance is created if necessary. |
|
3130 |
* |
|
3131 |
* @return an AccessibleAWTWindow that serves as the |
|
3132 |
* AccessibleContext of this Window |
|
3133 |
* @since 1.3 |
|
3134 |
*/ |
|
3135 |
public AccessibleContext getAccessibleContext() { |
|
3136 |
if (accessibleContext == null) { |
|
3137 |
accessibleContext = new AccessibleAWTWindow(); |
|
3138 |
} |
|
3139 |
return accessibleContext; |
|
3140 |
} |
|
3141 |
||
3142 |
/** |
|
3143 |
* This class implements accessibility support for the |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3144 |
* {@code Window} class. It provides an implementation of the |
2 | 3145 |
* Java Accessibility API appropriate to window user-interface elements. |
3146 |
* @since 1.3 |
|
3147 |
*/ |
|
3148 |
protected class AccessibleAWTWindow extends AccessibleAWTContainer |
|
3149 |
{ |
|
3150 |
/* |
|
3151 |
* JDK 1.3 serialVersionUID |
|
3152 |
*/ |
|
3153 |
private static final long serialVersionUID = 4215068635060671780L; |
|
3154 |
||
3155 |
/** |
|
3156 |
* Get the role of this object. |
|
3157 |
* |
|
3158 |
* @return an instance of AccessibleRole describing the role of the |
|
3159 |
* object |
|
3160 |
* @see javax.accessibility.AccessibleRole |
|
3161 |
*/ |
|
3162 |
public AccessibleRole getAccessibleRole() { |
|
3163 |
return AccessibleRole.WINDOW; |
|
3164 |
} |
|
3165 |
||
3166 |
/** |
|
3167 |
* Get the state of this object. |
|
3168 |
* |
|
3169 |
* @return an instance of AccessibleStateSet containing the current |
|
3170 |
* state set of the object |
|
3171 |
* @see javax.accessibility.AccessibleState |
|
3172 |
*/ |
|
3173 |
public AccessibleStateSet getAccessibleStateSet() { |
|
3174 |
AccessibleStateSet states = super.getAccessibleStateSet(); |
|
3175 |
if (getFocusOwner() != null) { |
|
3176 |
states.add(AccessibleState.ACTIVE); |
|
3177 |
} |
|
3178 |
return states; |
|
3179 |
} |
|
3180 |
||
3181 |
} // inner class AccessibleAWTWindow |
|
3182 |
||
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
3183 |
@Override |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
3184 |
void setGraphicsConfiguration(GraphicsConfiguration gc) { |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
3185 |
if (gc == null) { |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
3186 |
gc = GraphicsEnvironment. |
2 | 3187 |
getLocalGraphicsEnvironment(). |
3188 |
getDefaultScreenDevice(). |
|
3189 |
getDefaultConfiguration(); |
|
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
3190 |
} |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
3191 |
synchronized (getTreeLock()) { |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
3192 |
super.setGraphicsConfiguration(gc); |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
17901
diff
changeset
|
3193 |
if (log.isLoggable(PlatformLogger.Level.FINER)) { |
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
3194 |
log.finer("+ Window.setGraphicsConfiguration(): new GC is \n+ " + getGraphicsConfiguration_NoClientCode() + "\n+ this is " + this); |
2 | 3195 |
} |
3196 |
} |
|
3197 |
} |
|
3198 |
||
3199 |
/** |
|
3200 |
* Sets the location of the window relative to the specified |
|
3201 |
* component according to the following scenarios. |
|
3202 |
* <p> |
|
3203 |
* The target screen mentioned below is a screen to which |
|
3204 |
* the window should be placed after the setLocationRelativeTo |
|
3205 |
* method is called. |
|
3206 |
* <ul> |
|
3207 |
* <li>If the component is {@code null}, or the {@code |
|
3208 |
* GraphicsConfiguration} associated with this component is |
|
3209 |
* {@code null}, the window is placed in the center of the |
|
3210 |
* screen. The center point can be obtained with the {@link |
|
3211 |
* GraphicsEnvironment#getCenterPoint |
|
3212 |
* GraphicsEnvironment.getCenterPoint} method. |
|
3213 |
* <li>If the component is not {@code null}, but it is not |
|
3214 |
* currently showing, the window is placed in the center of |
|
3215 |
* the target screen defined by the {@code |
|
3216 |
* GraphicsConfiguration} associated with this component. |
|
3217 |
* <li>If the component is not {@code null} and is shown on |
|
3218 |
* the screen, then the window is located in such a way that |
|
3219 |
* the center of the window coincides with the center of the |
|
3220 |
* component. |
|
3221 |
* </ul> |
|
3222 |
* <p> |
|
3223 |
* If the screens configuration does not allow the window to |
|
3224 |
* be moved from one screen to another, then the window is |
|
3225 |
* only placed at the location determined according to the |
|
3226 |
* above conditions and its {@code GraphicsConfiguration} is |
|
3227 |
* not changed. |
|
3228 |
* <p> |
|
3229 |
* <b>Note</b>: If the lower edge of the window is out of the screen, |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3230 |
* then the window is placed to the side of the {@code Component} |
2 | 3231 |
* that is closest to the center of the screen. So if the |
3232 |
* component is on the right part of the screen, the window |
|
3233 |
* is placed to its left, and vice versa. |
|
3234 |
* <p> |
|
3235 |
* If after the window location has been calculated, the upper, |
|
3236 |
* left, or right edge of the window is out of the screen, |
|
3237 |
* then the window is located in such a way that the upper, |
|
3238 |
* left, or right edge of the window coincides with the |
|
3239 |
* corresponding edge of the screen. If both left and right |
|
3240 |
* edges of the window are out of the screen, the window is |
|
3241 |
* placed at the left side of the screen. The similar placement |
|
3242 |
* will occur if both top and bottom edges are out of the screen. |
|
3243 |
* In that case, the window is placed at the top side of the screen. |
|
9200
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
3244 |
* <p> |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
3245 |
* The method changes the geometry-related data. Therefore, |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
3246 |
* the native windowing system may ignore such requests, or it may modify |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
3247 |
* the requested data, so that the {@code Window} object is placed and sized |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
3248 |
* in a way that corresponds closely to the desktop settings. |
2 | 3249 |
* |
3250 |
* @param c the component in relation to which the window's location |
|
3251 |
* is determined |
|
3252 |
* @see java.awt.GraphicsEnvironment#getCenterPoint |
|
3253 |
* @since 1.4 |
|
3254 |
*/ |
|
3255 |
public void setLocationRelativeTo(Component c) { |
|
3256 |
// target location |
|
3257 |
int dx = 0, dy = 0; |
|
3258 |
// target GC |
|
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2455
diff
changeset
|
3259 |
GraphicsConfiguration gc = getGraphicsConfiguration_NoClientCode(); |
2 | 3260 |
Rectangle gcBounds = gc.getBounds(); |
3261 |
||
3262 |
Dimension windowSize = getSize(); |
|
3263 |
||
3264 |
// search a top-level of c |
|
2451 | 3265 |
Window componentWindow = SunToolkit.getContainingWindow(c); |
2 | 3266 |
if ((c == null) || (componentWindow == null)) { |
3267 |
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
|
3268 |
gc = ge.getDefaultScreenDevice().getDefaultConfiguration(); |
|
3269 |
gcBounds = gc.getBounds(); |
|
3270 |
Point centerPoint = ge.getCenterPoint(); |
|
3271 |
dx = centerPoint.x - windowSize.width / 2; |
|
3272 |
dy = centerPoint.y - windowSize.height / 2; |
|
3273 |
} else if (!c.isShowing()) { |
|
3274 |
gc = componentWindow.getGraphicsConfiguration(); |
|
3275 |
gcBounds = gc.getBounds(); |
|
3276 |
dx = gcBounds.x + (gcBounds.width - windowSize.width) / 2; |
|
3277 |
dy = gcBounds.y + (gcBounds.height - windowSize.height) / 2; |
|
3278 |
} else { |
|
3279 |
gc = componentWindow.getGraphicsConfiguration(); |
|
3280 |
gcBounds = gc.getBounds(); |
|
3281 |
Dimension compSize = c.getSize(); |
|
3282 |
Point compLocation = c.getLocationOnScreen(); |
|
3283 |
dx = compLocation.x + ((compSize.width - windowSize.width) / 2); |
|
3284 |
dy = compLocation.y + ((compSize.height - windowSize.height) / 2); |
|
3285 |
||
3286 |
// Adjust for bottom edge being offscreen |
|
3287 |
if (dy + windowSize.height > gcBounds.y + gcBounds.height) { |
|
3288 |
dy = gcBounds.y + gcBounds.height - windowSize.height; |
|
3289 |
if (compLocation.x - gcBounds.x + compSize.width / 2 < gcBounds.width / 2) { |
|
3290 |
dx = compLocation.x + compSize.width; |
|
3291 |
} else { |
|
3292 |
dx = compLocation.x - windowSize.width; |
|
3293 |
} |
|
3294 |
} |
|
3295 |
} |
|
3296 |
||
3297 |
// Avoid being placed off the edge of the screen: |
|
3298 |
// bottom |
|
3299 |
if (dy + windowSize.height > gcBounds.y + gcBounds.height) { |
|
3300 |
dy = gcBounds.y + gcBounds.height - windowSize.height; |
|
3301 |
} |
|
3302 |
// top |
|
3303 |
if (dy < gcBounds.y) { |
|
3304 |
dy = gcBounds.y; |
|
3305 |
} |
|
3306 |
// right |
|
3307 |
if (dx + windowSize.width > gcBounds.x + gcBounds.width) { |
|
3308 |
dx = gcBounds.x + gcBounds.width - windowSize.width; |
|
3309 |
} |
|
3310 |
// left |
|
3311 |
if (dx < gcBounds.x) { |
|
3312 |
dx = gcBounds.x; |
|
3313 |
} |
|
3314 |
||
3315 |
setLocation(dx, dy); |
|
3316 |
} |
|
3317 |
||
3318 |
/** |
|
3319 |
* Overridden from Component. Top-level Windows should not propagate a |
|
3320 |
* MouseWheelEvent beyond themselves into their owning Windows. |
|
3321 |
*/ |
|
3322 |
void deliverMouseWheelToAncestor(MouseWheelEvent e) {} |
|
3323 |
||
3324 |
/** |
|
3325 |
* Overridden from Component. Top-level Windows don't dispatch to ancestors |
|
3326 |
*/ |
|
3327 |
boolean dispatchMouseWheelToAncestor(MouseWheelEvent e) {return false;} |
|
3328 |
||
3329 |
/** |
|
3330 |
* Creates a new strategy for multi-buffering on this component. |
|
3331 |
* Multi-buffering is useful for rendering performance. This method |
|
3332 |
* attempts to create the best strategy available with the number of |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3333 |
* buffers supplied. It will always create a {@code BufferStrategy} |
2 | 3334 |
* with that number of buffers. |
3335 |
* A page-flipping strategy is attempted first, then a blitting strategy |
|
3336 |
* using accelerated buffers. Finally, an unaccelerated blitting |
|
3337 |
* strategy is used. |
|
3338 |
* <p> |
|
3339 |
* Each time this method is called, |
|
3340 |
* the existing buffer strategy for this component is discarded. |
|
3341 |
* @param numBuffers number of buffers to create |
|
3342 |
* @exception IllegalArgumentException if numBuffers is less than 1. |
|
3343 |
* @exception IllegalStateException if the component is not displayable |
|
3344 |
* @see #isDisplayable |
|
3345 |
* @see #getBufferStrategy |
|
3346 |
* @since 1.4 |
|
3347 |
*/ |
|
3348 |
public void createBufferStrategy(int numBuffers) { |
|
3349 |
super.createBufferStrategy(numBuffers); |
|
3350 |
} |
|
3351 |
||
3352 |
/** |
|
3353 |
* Creates a new strategy for multi-buffering on this component with the |
|
3354 |
* required buffer capabilities. This is useful, for example, if only |
|
3355 |
* accelerated memory or page flipping is desired (as specified by the |
|
3356 |
* buffer capabilities). |
|
3357 |
* <p> |
|
3358 |
* Each time this method |
|
3359 |
* is called, the existing buffer strategy for this component is discarded. |
|
3360 |
* @param numBuffers number of buffers to create, including the front buffer |
|
3361 |
* @param caps the required capabilities for creating the buffer strategy; |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3362 |
* cannot be {@code null} |
2 | 3363 |
* @exception AWTException if the capabilities supplied could not be |
3364 |
* supported or met; this may happen, for example, if there is not enough |
|
3365 |
* accelerated memory currently available, or if page flipping is specified |
|
3366 |
* but not possible. |
|
3367 |
* @exception IllegalArgumentException if numBuffers is less than 1, or if |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3368 |
* caps is {@code null} |
2 | 3369 |
* @see #getBufferStrategy |
3370 |
* @since 1.4 |
|
3371 |
*/ |
|
3372 |
public void createBufferStrategy(int numBuffers, |
|
3373 |
BufferCapabilities caps) throws AWTException { |
|
3374 |
super.createBufferStrategy(numBuffers, caps); |
|
3375 |
} |
|
3376 |
||
3377 |
/** |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3378 |
* Returns the {@code BufferStrategy} used by this component. This |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3379 |
* method will return null if a {@code BufferStrategy} has not yet |
2 | 3380 |
* been created or has been disposed. |
3381 |
* |
|
3382 |
* @return the buffer strategy used by this component |
|
3383 |
* @see #createBufferStrategy |
|
3384 |
* @since 1.4 |
|
3385 |
*/ |
|
3386 |
public BufferStrategy getBufferStrategy() { |
|
3387 |
return super.getBufferStrategy(); |
|
3388 |
} |
|
3389 |
||
3390 |
Component getTemporaryLostComponent() { |
|
3391 |
return temporaryLostComponent; |
|
3392 |
} |
|
3393 |
Component setTemporaryLostComponent(Component component) { |
|
3394 |
Component previousComp = temporaryLostComponent; |
|
3395 |
// Check that "component" is an acceptable focus owner and don't store it otherwise |
|
3396 |
// - or later we will have problems with opposite while handling WINDOW_GAINED_FOCUS |
|
1171
a2782dd9f312
4685768: A11y issue - Focus set to disabled component, can't Tab/Shift-Tab
ant
parents:
127
diff
changeset
|
3397 |
if (component == null || component.canBeFocusOwner()) { |
2 | 3398 |
temporaryLostComponent = component; |
3399 |
} else { |
|
3400 |
temporaryLostComponent = null; |
|
3401 |
} |
|
3402 |
return previousComp; |
|
3403 |
} |
|
3404 |
||
3405 |
/** |
|
3406 |
* Checks whether this window can contain focus owner. |
|
3407 |
* Verifies that it is focusable and as container it can container focus owner. |
|
3408 |
* @since 1.5 |
|
3409 |
*/ |
|
3410 |
boolean canContainFocusOwner(Component focusOwnerCandidate) { |
|
3411 |
return super.canContainFocusOwner(focusOwnerCandidate) && isFocusableWindow(); |
|
3412 |
} |
|
3413 |
||
33510
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
32865
diff
changeset
|
3414 |
private volatile boolean locationByPlatform = locationByPlatformProp; |
2 | 3415 |
|
3416 |
||
3417 |
/** |
|
3418 |
* Sets whether this Window should appear at the default location for the |
|
3419 |
* native windowing system or at the current location (returned by |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3420 |
* {@code getLocation}) the next time the Window is made visible. |
2 | 3421 |
* This behavior resembles a native window shown without programmatically |
3422 |
* setting its location. Most windowing systems cascade windows if their |
|
3423 |
* locations are not explicitly set. The actual location is determined once the |
|
3424 |
* window is shown on the screen. |
|
3425 |
* <p> |
|
3426 |
* This behavior can also be enabled by setting the System Property |
|
3427 |
* "java.awt.Window.locationByPlatform" to "true", though calls to this method |
|
3428 |
* take precedence. |
|
3429 |
* <p> |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3430 |
* Calls to {@code setVisible}, {@code setLocation} and |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3431 |
* {@code setBounds} after calling {@code setLocationByPlatform} clear |
2 | 3432 |
* this property of the Window. |
3433 |
* <p> |
|
3434 |
* For example, after the following code is executed: |
|
20172 | 3435 |
* <pre> |
2 | 3436 |
* setLocationByPlatform(true); |
3437 |
* setVisible(true); |
|
3438 |
* boolean flag = isLocationByPlatform(); |
|
20172 | 3439 |
* </pre> |
2 | 3440 |
* The window will be shown at platform's default location and |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3441 |
* {@code flag} will be {@code false}. |
2 | 3442 |
* <p> |
3443 |
* In the following sample: |
|
20172 | 3444 |
* <pre> |
2 | 3445 |
* setLocationByPlatform(true); |
3446 |
* setLocation(10, 10); |
|
3447 |
* boolean flag = isLocationByPlatform(); |
|
3448 |
* setVisible(true); |
|
20172 | 3449 |
* </pre> |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3450 |
* The window will be shown at (10, 10) and {@code flag} will be |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3451 |
* {@code false}. |
2 | 3452 |
* |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3453 |
* @param locationByPlatform {@code true} if this Window should appear |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3454 |
* at the default location, {@code false} if at the current location |
20172 | 3455 |
* @throws IllegalComponentStateException if the window |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3456 |
* is showing on screen and locationByPlatform is {@code true}. |
2 | 3457 |
* @see #setLocation |
3458 |
* @see #isShowing |
|
3459 |
* @see #setVisible |
|
3460 |
* @see #isLocationByPlatform |
|
3461 |
* @see java.lang.System#getProperty(String) |
|
3462 |
* @since 1.5 |
|
3463 |
*/ |
|
3464 |
public void setLocationByPlatform(boolean locationByPlatform) { |
|
3465 |
synchronized (getTreeLock()) { |
|
3466 |
if (locationByPlatform && isShowing()) { |
|
3467 |
throw new IllegalComponentStateException("The window is showing on screen."); |
|
3468 |
} |
|
3469 |
this.locationByPlatform = locationByPlatform; |
|
3470 |
} |
|
3471 |
} |
|
3472 |
||
3473 |
/** |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3474 |
* Returns {@code true} if this Window will appear at the default location |
2 | 3475 |
* for the native windowing system the next time this Window is made visible. |
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3476 |
* This method always returns {@code false} if the Window is showing on the |
2 | 3477 |
* screen. |
3478 |
* |
|
3479 |
* @return whether this Window will appear at the default location |
|
3480 |
* @see #setLocationByPlatform |
|
3481 |
* @see #isShowing |
|
3482 |
* @since 1.5 |
|
3483 |
*/ |
|
3484 |
public boolean isLocationByPlatform() { |
|
33510
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
32865
diff
changeset
|
3485 |
return locationByPlatform; |
2 | 3486 |
} |
3487 |
||
3488 |
/** |
|
3489 |
* {@inheritDoc} |
|
3490 |
* <p> |
|
3491 |
* The {@code width} or {@code height} values |
|
3492 |
* are automatically enlarged if either is less than |
|
3493 |
* the minimum size as specified by previous call to |
|
3494 |
* {@code setMinimumSize}. |
|
9200
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
3495 |
* <p> |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
3496 |
* The method changes the geometry-related data. Therefore, |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
3497 |
* the native windowing system may ignore such requests, or it may modify |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
3498 |
* the requested data, so that the {@code Window} object is placed and sized |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
3499 |
* in a way that corresponds closely to the desktop settings. |
2 | 3500 |
* |
3501 |
* @see #getBounds |
|
3502 |
* @see #setLocation(int, int) |
|
3503 |
* @see #setLocation(Point) |
|
3504 |
* @see #setSize(int, int) |
|
3505 |
* @see #setSize(Dimension) |
|
3506 |
* @see #setMinimumSize |
|
3507 |
* @see #setLocationByPlatform |
|
3508 |
* @see #isLocationByPlatform |
|
3509 |
* @since 1.6 |
|
3510 |
*/ |
|
3511 |
public void setBounds(int x, int y, int width, int height) { |
|
3512 |
synchronized (getTreeLock()) { |
|
3513 |
if (getBoundsOp() == ComponentPeer.SET_LOCATION || |
|
3514 |
getBoundsOp() == ComponentPeer.SET_BOUNDS) |
|
3515 |
{ |
|
3516 |
locationByPlatform = false; |
|
3517 |
} |
|
3518 |
super.setBounds(x, y, width, height); |
|
3519 |
} |
|
3520 |
} |
|
3521 |
||
3522 |
/** |
|
3523 |
* {@inheritDoc} |
|
3524 |
* <p> |
|
3525 |
* The {@code r.width} or {@code r.height} values |
|
3526 |
* will be automatically enlarged if either is less than |
|
3527 |
* the minimum size as specified by previous call to |
|
3528 |
* {@code setMinimumSize}. |
|
9200
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
3529 |
* <p> |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
3530 |
* The method changes the geometry-related data. Therefore, |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
3531 |
* the native windowing system may ignore such requests, or it may modify |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
3532 |
* the requested data, so that the {@code Window} object is placed and sized |
d3e9a8fecd4f
7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct
dcherepanov
parents:
8136
diff
changeset
|
3533 |
* in a way that corresponds closely to the desktop settings. |
2 | 3534 |
* |
3535 |
* @see #getBounds |
|
3536 |
* @see #setLocation(int, int) |
|
3537 |
* @see #setLocation(Point) |
|
3538 |
* @see #setSize(int, int) |
|
3539 |
* @see #setSize(Dimension) |
|
3540 |
* @see #setMinimumSize |
|
3541 |
* @see #setLocationByPlatform |
|
3542 |
* @see #isLocationByPlatform |
|
3543 |
* @since 1.6 |
|
3544 |
*/ |
|
3545 |
public void setBounds(Rectangle r) { |
|
3546 |
setBounds(r.x, r.y, r.width, r.height); |
|
3547 |
} |
|
3548 |
||
3549 |
/** |
|
3550 |
* Determines whether this component will be displayed on the screen. |
|
19361
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3551 |
* @return {@code true} if the component and all of its ancestors |
424d84a2276f
7027045: (doc) java/awt/Window.java has several typos in javadoc
serb
parents:
18178
diff
changeset
|
3552 |
* until a toplevel window are visible, {@code false} otherwise |
2 | 3553 |
*/ |
3554 |
boolean isRecursivelyVisible() { |
|
3555 |
// 5079694 fix: for a toplevel to be displayed, its parent doesn't have to be visible. |
|
3556 |
// We're overriding isRecursivelyVisible to implement this policy. |
|
3557 |
return visible; |
|
3558 |
} |
|
3559 |
||
3560 |
||
2451 | 3561 |
// ******************** SHAPES & TRANSPARENCY CODE ******************** |
3562 |
||
3563 |
/** |
|
2648 | 3564 |
* Returns the opacity of the window. |
3565 |
* |
|
3566 |
* @return the opacity of the window |
|
3567 |
* |
|
3711
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3568 |
* @see Window#setOpacity(float) |
2648 | 3569 |
* @see GraphicsDevice.WindowTranslucency |
3570 |
* |
|
3571 |
* @since 1.7 |
|
2451 | 3572 |
*/ |
2648 | 3573 |
public float getOpacity() { |
33510
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
32865
diff
changeset
|
3574 |
return opacity; |
2451 | 3575 |
} |
3576 |
||
3577 |
/** |
|
2648 | 3578 |
* Sets the opacity of the window. |
3579 |
* <p> |
|
3580 |
* The opacity value is in the range [0..1]. Note that setting the opacity |
|
3581 |
* level of 0 may or may not disable the mouse event handling on this |
|
3582 |
* window. This is a platform-dependent behavior. |
|
3583 |
* <p> |
|
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3584 |
* The following conditions must be met in order to set the opacity value |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3585 |
* less than {@code 1.0f}: |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3586 |
* <ul> |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3587 |
* <li>The {@link GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT} |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3588 |
* translucency must be supported by the underlying system |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3589 |
* <li>The window must be undecorated (see {@link Frame#setUndecorated} |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3590 |
* and {@link Dialog#setUndecorated}) |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3591 |
* <li>The window must not be in full-screen mode (see {@link |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3592 |
* GraphicsDevice#setFullScreenWindow(Window)}) |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3593 |
* </ul> |
2648 | 3594 |
* <p> |
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3595 |
* If the requested opacity value is less than {@code 1.0f}, and any of the |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3596 |
* above conditions are not met, the window opacity will not change, |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3597 |
* and the {@code IllegalComponentStateException} will be thrown. |
2648 | 3598 |
* <p> |
3599 |
* The translucency levels of individual pixels may also be effected by the |
|
3711
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3600 |
* alpha component of their color (see {@link Window#setBackground(Color)}) and the |
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3601 |
* current shape of this window (see {@link #setShape(Shape)}). |
2648 | 3602 |
* |
3603 |
* @param opacity the opacity level to set to the window |
|
3604 |
* |
|
3605 |
* @throws IllegalArgumentException if the opacity is out of the range |
|
3606 |
* [0..1] |
|
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3607 |
* @throws IllegalComponentStateException if the window is decorated and |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3608 |
* the opacity is less than {@code 1.0f} |
2648 | 3609 |
* @throws IllegalComponentStateException if the window is in full screen |
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3610 |
* mode, and the opacity is less than {@code 1.0f} |
2648 | 3611 |
* @throws UnsupportedOperationException if the {@code |
3612 |
* GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT} |
|
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3613 |
* translucency is not supported and the opacity is less than |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3614 |
* {@code 1.0f} |
2648 | 3615 |
* |
3616 |
* @see Window#getOpacity |
|
3711
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3617 |
* @see Window#setBackground(Color) |
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3618 |
* @see Window#setShape(Shape) |
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3619 |
* @see Frame#isUndecorated |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3620 |
* @see Dialog#isUndecorated |
2648 | 3621 |
* @see GraphicsDevice.WindowTranslucency |
3711
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3622 |
* @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency) |
2648 | 3623 |
* |
3624 |
* @since 1.7 |
|
2451 | 3625 |
*/ |
28231
b608ffcaed74
8066621: Suppress deprecation warnings in java.desktop module
darcy
parents:
27766
diff
changeset
|
3626 |
@SuppressWarnings("deprecation") |
2648 | 3627 |
public void setOpacity(float opacity) { |
2451 | 3628 |
synchronized (getTreeLock()) { |
3629 |
if (opacity < 0.0f || opacity > 1.0f) { |
|
3630 |
throw new IllegalArgumentException( |
|
3631 |
"The value of opacity should be in the range [0.0f .. 1.0f]."); |
|
3632 |
} |
|
2648 | 3633 |
if (opacity < 1.0f) { |
3634 |
GraphicsConfiguration gc = getGraphicsConfiguration(); |
|
3635 |
GraphicsDevice gd = gc.getDevice(); |
|
3636 |
if (gc.getDevice().getFullScreenWindow() == this) { |
|
3637 |
throw new IllegalComponentStateException( |
|
3638 |
"Setting opacity for full-screen window is not supported."); |
|
3639 |
} |
|
3640 |
if (!gd.isWindowTranslucencySupported( |
|
3641 |
GraphicsDevice.WindowTranslucency.TRANSLUCENT)) |
|
3642 |
{ |
|
3643 |
throw new UnsupportedOperationException( |
|
2451 | 3644 |
"TRANSLUCENT translucency is not supported."); |
2648 | 3645 |
} |
2451 | 3646 |
} |
3647 |
this.opacity = opacity; |
|
30469 | 3648 |
WindowPeer peer = (WindowPeer) this.peer; |
2451 | 3649 |
if (peer != null) { |
3650 |
peer.setOpacity(opacity); |
|
3651 |
} |
|
3652 |
} |
|
3653 |
} |
|
3654 |
||
3655 |
/** |
|
2648 | 3656 |
* Returns the shape of the window. |
3657 |
* |
|
3658 |
* The value returned by this method may not be the same as |
|
3659 |
* previously set with {@code setShape(shape)}, but it is guaranteed |
|
3660 |
* to represent the same shape. |
|
3661 |
* |
|
3662 |
* @return the shape of the window or {@code null} if no |
|
3663 |
* shape is specified for the window |
|
3664 |
* |
|
3711
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3665 |
* @see Window#setShape(Shape) |
2648 | 3666 |
* @see GraphicsDevice.WindowTranslucency |
3667 |
* |
|
3668 |
* @since 1.7 |
|
2451 | 3669 |
*/ |
2648 | 3670 |
public Shape getShape() { |
2451 | 3671 |
synchronized (getTreeLock()) { |
2648 | 3672 |
return shape == null ? null : new Path2D.Float(shape); |
2451 | 3673 |
} |
3674 |
} |
|
3675 |
||
3676 |
/** |
|
2648 | 3677 |
* Sets the shape of the window. |
3678 |
* <p> |
|
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3679 |
* Setting a shape cuts off some parts of the window. Only the parts that |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3680 |
* belong to the given {@link Shape} remain visible and clickable. If |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3681 |
* the shape argument is {@code null}, this method restores the default |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3682 |
* shape, making the window rectangular on most platforms. |
2648 | 3683 |
* <p> |
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3684 |
* The following conditions must be met to set a non-null shape: |
2648 | 3685 |
* <ul> |
3686 |
* <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT |
|
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3687 |
* PERPIXEL_TRANSPARENT} translucency must be supported by the |
3711
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3688 |
* underlying system |
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3689 |
* <li>The window must be undecorated (see {@link Frame#setUndecorated} |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3690 |
* and {@link Dialog#setUndecorated}) |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3691 |
* <li>The window must not be in full-screen mode (see {@link |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3692 |
* GraphicsDevice#setFullScreenWindow(Window)}) |
2648 | 3693 |
* </ul> |
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3694 |
* <p> |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3695 |
* If the requested shape is not {@code null}, and any of the above |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3696 |
* conditions are not met, the shape of this window will not change, |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3697 |
* and either the {@code UnsupportedOperationException} or {@code |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3698 |
* IllegalComponentStateException} will be thrown. |
2648 | 3699 |
* <p> |
21278 | 3700 |
* The translucency levels of individual pixels may also be effected by the |
3711
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3701 |
* alpha component of their color (see {@link Window#setBackground(Color)}) and the |
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3702 |
* opacity value (see {@link #setOpacity(float)}). See {@link |
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3703 |
* GraphicsDevice.WindowTranslucency} for more details. |
2451 | 3704 |
* |
3705 |
* @param shape the shape to set to the window |
|
2648 | 3706 |
* |
3707 |
* @throws IllegalComponentStateException if the shape is not {@code |
|
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3708 |
* null} and the window is decorated |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3709 |
* @throws IllegalComponentStateException if the shape is not {@code |
2648 | 3710 |
* null} and the window is in full-screen mode |
3711 |
* @throws UnsupportedOperationException if the shape is not {@code |
|
3712 |
* null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT |
|
3713 |
* PERPIXEL_TRANSPARENT} translucency is not supported |
|
3714 |
* |
|
3715 |
* @see Window#getShape() |
|
3711
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3716 |
* @see Window#setBackground(Color) |
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3717 |
* @see Window#setOpacity(float) |
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3718 |
* @see Frame#isUndecorated |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3719 |
* @see Dialog#isUndecorated |
2648 | 3720 |
* @see GraphicsDevice.WindowTranslucency |
3711
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3721 |
* @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency) |
2648 | 3722 |
* |
3723 |
* @since 1.7 |
|
2451 | 3724 |
*/ |
2648 | 3725 |
public void setShape(Shape shape) { |
2451 | 3726 |
synchronized (getTreeLock()) { |
2648 | 3727 |
if (shape != null) { |
3728 |
GraphicsConfiguration gc = getGraphicsConfiguration(); |
|
3729 |
GraphicsDevice gd = gc.getDevice(); |
|
3730 |
if (gc.getDevice().getFullScreenWindow() == this) { |
|
3731 |
throw new IllegalComponentStateException( |
|
3732 |
"Setting shape for full-screen window is not supported."); |
|
3733 |
} |
|
3734 |
if (!gd.isWindowTranslucencySupported( |
|
3735 |
GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT)) |
|
3736 |
{ |
|
3737 |
throw new UnsupportedOperationException( |
|
2451 | 3738 |
"PERPIXEL_TRANSPARENT translucency is not supported."); |
2648 | 3739 |
} |
2451 | 3740 |
} |
2648 | 3741 |
this.shape = (shape == null) ? null : new Path2D.Float(shape); |
30469 | 3742 |
WindowPeer peer = (WindowPeer) this.peer; |
2451 | 3743 |
if (peer != null) { |
3744 |
peer.applyShape(shape == null ? null : Region.getInstance(shape, null)); |
|
3745 |
} |
|
3746 |
} |
|
3747 |
} |
|
3748 |
||
3749 |
/** |
|
2648 | 3750 |
* Gets the background color of this window. |
3751 |
* <p> |
|
3752 |
* Note that the alpha component of the returned color indicates whether |
|
3753 |
* the window is in the non-opaque (per-pixel translucent) mode. |
|
3754 |
* |
|
3755 |
* @return this component's background color |
|
3756 |
* |
|
3711
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3757 |
* @see Window#setBackground(Color) |
3237 | 3758 |
* @see Window#isOpaque |
2648 | 3759 |
* @see GraphicsDevice.WindowTranslucency |
2451 | 3760 |
*/ |
2648 | 3761 |
@Override |
3762 |
public Color getBackground() { |
|
3763 |
return super.getBackground(); |
|
3764 |
} |
|
3765 |
||
3766 |
/** |
|
3767 |
* Sets the background color of this window. |
|
3768 |
* <p> |
|
3769 |
* If the windowing system supports the {@link |
|
3770 |
* GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT PERPIXEL_TRANSLUCENT} |
|
21278 | 3771 |
* translucency, the alpha component of the given background color |
2648 | 3772 |
* may effect the mode of operation for this window: it indicates whether |
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3773 |
* this window must be opaque (alpha equals {@code 1.0f}) or per-pixel translucent |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3774 |
* (alpha is less than {@code 1.0f}). If the given background color is |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3775 |
* {@code null}, the window is considered completely opaque. |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3776 |
* <p> |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3777 |
* All the following conditions must be met to enable the per-pixel |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3778 |
* transparency mode for this window: |
2648 | 3779 |
* <ul> |
3780 |
* <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT |
|
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3781 |
* PERPIXEL_TRANSLUCENT} translucency must be supported by the graphics |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3782 |
* device where this window is located |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3783 |
* <li>The window must be undecorated (see {@link Frame#setUndecorated} |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3784 |
* and {@link Dialog#setUndecorated}) |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3785 |
* <li>The window must not be in full-screen mode (see {@link |
3711
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3786 |
* GraphicsDevice#setFullScreenWindow(Window)}) |
2648 | 3787 |
* </ul> |
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3788 |
* <p> |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3789 |
* If the alpha component of the requested background color is less than |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3790 |
* {@code 1.0f}, and any of the above conditions are not met, the background |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3791 |
* color of this window will not change, the alpha component of the given |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3792 |
* background color will not affect the mode of operation for this window, |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3793 |
* and either the {@code UnsupportedOperationException} or {@code |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3794 |
* IllegalComponentStateException} will be thrown. |
2648 | 3795 |
* <p> |
3796 |
* When the window is per-pixel translucent, the drawing sub-system |
|
3797 |
* respects the alpha value of each individual pixel. If a pixel gets |
|
3798 |
* painted with the alpha color component equal to zero, it becomes |
|
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3799 |
* visually transparent. If the alpha of the pixel is equal to 1.0f, the |
2648 | 3800 |
* pixel is fully opaque. Interim values of the alpha color component make |
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3801 |
* the pixel semi-transparent. In this mode, the background of the window |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3802 |
* gets painted with the alpha value of the given background color. If the |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3803 |
* alpha value of the argument of this method is equal to {@code 0}, the |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3804 |
* background is not painted at all. |
2648 | 3805 |
* <p> |
3806 |
* The actual level of translucency of a given pixel also depends on window |
|
3711
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3807 |
* opacity (see {@link #setOpacity(float)}), as well as the current shape of |
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3808 |
* this window (see {@link #setShape(Shape)}). |
2648 | 3809 |
* <p> |
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3810 |
* Note that painting a pixel with the alpha value of {@code 0} may or may |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3811 |
* not disable the mouse event handling on this pixel. This is a |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3812 |
* platform-dependent behavior. To make sure the mouse events do not get |
2648 | 3813 |
* dispatched to a particular pixel, the pixel must be excluded from the |
3814 |
* shape of the window. |
|
3815 |
* <p> |
|
3816 |
* Enabling the per-pixel translucency mode may change the graphics |
|
3817 |
* configuration of this window due to the native platform requirements. |
|
3818 |
* |
|
3819 |
* @param bgColor the color to become this window's background color. |
|
3820 |
* |
|
3821 |
* @throws IllegalComponentStateException if the alpha value of the given |
|
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3822 |
* background color is less than {@code 1.0f} and the window is decorated |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3823 |
* @throws IllegalComponentStateException if the alpha value of the given |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3824 |
* background color is less than {@code 1.0f} and the window is in |
2648 | 3825 |
* full-screen mode |
3826 |
* @throws UnsupportedOperationException if the alpha value of the given |
|
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3827 |
* background color is less than {@code 1.0f} and {@link |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3828 |
* GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT |
2648 | 3829 |
* PERPIXEL_TRANSLUCENT} translucency is not supported |
3830 |
* |
|
3831 |
* @see Window#getBackground |
|
3237 | 3832 |
* @see Window#isOpaque |
3711
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3833 |
* @see Window#setOpacity(float) |
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3834 |
* @see Window#setShape(Shape) |
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3835 |
* @see Frame#isUndecorated |
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3836 |
* @see Dialog#isUndecorated |
2648 | 3837 |
* @see GraphicsDevice.WindowTranslucency |
3711
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3838 |
* @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency) |
2648 | 3839 |
* @see GraphicsConfiguration#isTranslucencyCapable() |
3840 |
*/ |
|
2451 | 3841 |
@Override |
3842 |
public void setBackground(Color bgColor) { |
|
2648 | 3843 |
Color oldBg = getBackground(); |
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3844 |
super.setBackground(bgColor); |
2648 | 3845 |
if (oldBg != null && oldBg.equals(bgColor)) { |
3846 |
return; |
|
3847 |
} |
|
3848 |
int oldAlpha = oldBg != null ? oldBg.getAlpha() : 255; |
|
3231
10acb97474ff
6853916: java.awt.Window.setBackground(null) throws NullPointerException
anthony
parents:
3084
diff
changeset
|
3849 |
int alpha = bgColor != null ? bgColor.getAlpha() : 255; |
2648 | 3850 |
if ((oldAlpha == 255) && (alpha < 255)) { // non-opaque window |
2451 | 3851 |
GraphicsConfiguration gc = getGraphicsConfiguration(); |
3852 |
GraphicsDevice gd = gc.getDevice(); |
|
3853 |
if (gc.getDevice().getFullScreenWindow() == this) { |
|
2648 | 3854 |
throw new IllegalComponentStateException( |
2451 | 3855 |
"Making full-screen window non opaque is not supported."); |
3856 |
} |
|
3857 |
if (!gc.isTranslucencyCapable()) { |
|
3858 |
GraphicsConfiguration capableGC = gd.getTranslucencyCapableGC(); |
|
3859 |
if (capableGC == null) { |
|
2648 | 3860 |
throw new UnsupportedOperationException( |
2451 | 3861 |
"PERPIXEL_TRANSLUCENT translucency is not supported"); |
3862 |
} |
|
2648 | 3863 |
setGraphicsConfiguration(capableGC); |
2451 | 3864 |
} |
3865 |
setLayersOpaque(this, false); |
|
2648 | 3866 |
} else if ((oldAlpha < 255) && (alpha == 255)) { |
3867 |
setLayersOpaque(this, true); |
|
2451 | 3868 |
} |
30469 | 3869 |
WindowPeer peer = (WindowPeer) this.peer; |
2451 | 3870 |
if (peer != null) { |
3871 |
peer.setOpaque(alpha == 255); |
|
3872 |
} |
|
3873 |
} |
|
3874 |
||
3237 | 3875 |
/** |
3876 |
* Indicates if the window is currently opaque. |
|
3877 |
* <p> |
|
3878 |
* The method returns {@code false} if the background color of the window |
|
3879 |
* is not {@code null} and the alpha component of the color is less than |
|
7236
e7c280629f58
6993784: Clarification to shaped/translucent windows specification is required
art
parents:
7154
diff
changeset
|
3880 |
* {@code 1.0f}. The method returns {@code true} otherwise. |
3237 | 3881 |
* |
3882 |
* @return {@code true} if the window is opaque, {@code false} otherwise |
|
3883 |
* |
|
3884 |
* @see Window#getBackground |
|
3711
675253c23780
6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents:
3476
diff
changeset
|
3885 |
* @see Window#setBackground(Color) |
3237 | 3886 |
* @since 1.7 |
3887 |
*/ |
|
3888 |
@Override |
|
3889 |
public boolean isOpaque() { |
|
3890 |
Color bg = getBackground(); |
|
3891 |
return bg != null ? bg.getAlpha() == 255 : true; |
|
3892 |
} |
|
3893 |
||
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3894 |
private void updateWindow() { |
2451 | 3895 |
synchronized (getTreeLock()) { |
30469 | 3896 |
WindowPeer peer = (WindowPeer) this.peer; |
2451 | 3897 |
if (peer != null) { |
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3898 |
peer.updateWindow(); |
2451 | 3899 |
} |
3900 |
} |
|
3901 |
} |
|
3902 |
||
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3903 |
/** |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3904 |
* {@inheritDoc} |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3905 |
* |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3906 |
* @since 1.7 |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3907 |
*/ |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3908 |
@Override |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3909 |
public void paint(Graphics g) { |
3237 | 3910 |
if (!isOpaque()) { |
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3911 |
Graphics gg = g.create(); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3912 |
try { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3913 |
if (gg instanceof Graphics2D) { |
3237 | 3914 |
gg.setColor(getBackground()); |
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3915 |
((Graphics2D)gg).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC)); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3916 |
gg.fillRect(0, 0, getWidth(), getHeight()); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3917 |
} |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3918 |
} finally { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3919 |
gg.dispose(); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3920 |
} |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3921 |
} |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3922 |
super.paint(g); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
3923 |
} |
2451 | 3924 |
|
3925 |
private static void setLayersOpaque(Component component, boolean isOpaque) { |
|
3926 |
// Shouldn't use instanceof to avoid loading Swing classes |
|
3927 |
// if it's a pure AWT application. |
|
3084
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
2808
diff
changeset
|
3928 |
if (SunToolkit.isInstanceOf(component, "javax.swing.RootPaneContainer")) { |
2451 | 3929 |
javax.swing.RootPaneContainer rpc = (javax.swing.RootPaneContainer)component; |
3930 |
javax.swing.JRootPane root = rpc.getRootPane(); |
|
3931 |
javax.swing.JLayeredPane lp = root.getLayeredPane(); |
|
3932 |
Container c = root.getContentPane(); |
|
3933 |
javax.swing.JComponent content = |
|
3934 |
(c instanceof javax.swing.JComponent) ? (javax.swing.JComponent)c : null; |
|
3935 |
lp.setOpaque(isOpaque); |
|
3936 |
root.setOpaque(isOpaque); |
|
3937 |
if (content != null) { |
|
3938 |
content.setOpaque(isOpaque); |
|
3939 |
||
3940 |
// Iterate down one level to see whether we have a JApplet |
|
3941 |
// (which is also a RootPaneContainer) which requires processing |
|
3942 |
int numChildren = content.getComponentCount(); |
|
3943 |
if (numChildren > 0) { |
|
3944 |
Component child = content.getComponent(0); |
|
3945 |
// It's OK to use instanceof here because we've |
|
3946 |
// already loaded the RootPaneContainer class by now |
|
3947 |
if (child instanceof javax.swing.RootPaneContainer) { |
|
3948 |
setLayersOpaque(child, isOpaque); |
|
3949 |
} |
|
3950 |
} |
|
3951 |
} |
|
3952 |
} |
|
3953 |
} |
|
3954 |
||
3955 |
||
2 | 3956 |
// ************************** MIXING CODE ******************************* |
3957 |
||
17150
a842e8c6660a
7166296: closed/java/awt/Frame/DisabledParentOfToplevel/DisabledParentOfToplevel.html failed since 1.8.0b36
serb
parents:
16892
diff
changeset
|
3958 |
// A window has an owner, but it does NOT have a container |
2 | 3959 |
@Override |
3960 |
final Container getContainer() { |
|
3961 |
return null; |
|
3962 |
} |
|
3963 |
||
3964 |
/** |
|
3965 |
* Applies the shape to the component |
|
3966 |
* @param shape Shape to be applied to the component |
|
3967 |
*/ |
|
3968 |
@Override |
|
3969 |
final void applyCompoundShape(Region shape) { |
|
3970 |
// The shape calculated by mixing code is not intended to be applied |
|
3971 |
// to windows or frames |
|
3972 |
} |
|
3973 |
||
3974 |
@Override |
|
3975 |
final void applyCurrentShape() { |
|
3976 |
// The shape calculated by mixing code is not intended to be applied |
|
3977 |
// to windows or frames |
|
3978 |
} |
|
3979 |
||
3980 |
@Override |
|
3981 |
final void mixOnReshaping() { |
|
3982 |
// The shape calculated by mixing code is not intended to be applied |
|
3983 |
// to windows or frames |
|
3984 |
} |
|
3985 |
||
3986 |
@Override |
|
3987 |
final Point getLocationOnWindow() { |
|
3988 |
return new Point(0, 0); |
|
3989 |
} |
|
3990 |
||
3991 |
// ****************** END OF MIXING CODE ******************************** |
|
3992 |
||
3444
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
3993 |
/** |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
3994 |
* Limit the given double value with the given range. |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
3995 |
*/ |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
3996 |
private static double limit(double value, double min, double max) { |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
3997 |
value = Math.max(value, min); |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
3998 |
value = Math.min(value, max); |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
3999 |
return value; |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4000 |
} |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4001 |
|
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4002 |
/** |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4003 |
* Calculate the position of the security warning. |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4004 |
* |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4005 |
* This method gets the window location/size as reported by the native |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4006 |
* system since the locally cached values may represent outdated data. |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4007 |
* |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4008 |
* The method is used from the native code, or via AWTAccessor. |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4009 |
* |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4010 |
* NOTE: this method is invoked on the toolkit thread, and therefore is not |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4011 |
* supposed to become public/user-overridable. |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4012 |
*/ |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4013 |
private Point2D calculateSecurityWarningPosition(double x, double y, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4014 |
double w, double h) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4015 |
{ |
3444
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4016 |
// The position according to the spec of SecurityWarning.setPosition() |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4017 |
double wx = x + w * securityWarningAlignmentX + securityWarningPointX; |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4018 |
double wy = y + h * securityWarningAlignmentY + securityWarningPointY; |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4019 |
|
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4020 |
// First, make sure the warning is not too far from the window bounds |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4021 |
wx = Window.limit(wx, |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4022 |
x - securityWarningWidth - 2, |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4023 |
x + w + 2); |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4024 |
wy = Window.limit(wy, |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4025 |
y - securityWarningHeight - 2, |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4026 |
y + h + 2); |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4027 |
|
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4028 |
// Now make sure the warning window is visible on the screen |
3446
4a07252d2e92
6736293: OpenType checks can be bypassed through finalizer resurrection
emcmanus
parents:
3444
diff
changeset
|
4029 |
GraphicsConfiguration graphicsConfig = |
4a07252d2e92
6736293: OpenType checks can be bypassed through finalizer resurrection
emcmanus
parents:
3444
diff
changeset
|
4030 |
getGraphicsConfiguration_NoClientCode(); |
3444
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4031 |
Rectangle screenBounds = graphicsConfig.getBounds(); |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4032 |
Insets screenInsets = |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4033 |
Toolkit.getDefaultToolkit().getScreenInsets(graphicsConfig); |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4034 |
|
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4035 |
wx = Window.limit(wx, |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4036 |
screenBounds.x + screenInsets.left, |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4037 |
screenBounds.x + screenBounds.width - screenInsets.right |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4038 |
- securityWarningWidth); |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4039 |
wy = Window.limit(wy, |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4040 |
screenBounds.y + screenInsets.top, |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4041 |
screenBounds.y + screenBounds.height - screenInsets.bottom |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4042 |
- securityWarningHeight); |
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4043 |
|
18840bd1c784
6818787: It is possible to reposition the security icon too far from the border of the window on X11
anthony
parents:
2472
diff
changeset
|
4044 |
return new Point2D.Double(wx, wy); |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4045 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4046 |
|
2451 | 4047 |
static { |
4048 |
AWTAccessor.setWindowAccessor(new AWTAccessor.WindowAccessor() { |
|
4049 |
public float getOpacity(Window window) { |
|
4050 |
return window.opacity; |
|
4051 |
} |
|
4052 |
public void setOpacity(Window window, float opacity) { |
|
4053 |
window.setOpacity(opacity); |
|
4054 |
} |
|
4055 |
public Shape getShape(Window window) { |
|
4056 |
return window.getShape(); |
|
4057 |
} |
|
4058 |
public void setShape(Window window, Shape shape) { |
|
4059 |
window.setShape(shape); |
|
4060 |
} |
|
4061 |
public void setOpaque(Window window, boolean opaque) { |
|
4062 |
Color bg = window.getBackground(); |
|
2648 | 4063 |
if (bg == null) { |
4064 |
bg = new Color(0, 0, 0, 0); |
|
4065 |
} |
|
2451 | 4066 |
window.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue(), |
4067 |
opaque ? 255 : 0)); |
|
4068 |
} |
|
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
4069 |
public void updateWindow(Window window) { |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2648
diff
changeset
|
4070 |
window.updateWindow(); |
2451 | 4071 |
} |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4072 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4073 |
public Dimension getSecurityWarningSize(Window window) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4074 |
return new Dimension(window.securityWarningWidth, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4075 |
window.securityWarningHeight); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4076 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4077 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4078 |
public void setSecurityWarningSize(Window window, int width, int height) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4079 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4080 |
window.securityWarningWidth = width; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4081 |
window.securityWarningHeight = height; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4082 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4083 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4084 |
public void setSecurityWarningPosition(Window window, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4085 |
Point2D point, float alignmentX, float alignmentY) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4086 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4087 |
window.securityWarningPointX = point.getX(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4088 |
window.securityWarningPointY = point.getY(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4089 |
window.securityWarningAlignmentX = alignmentX; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4090 |
window.securityWarningAlignmentY = alignmentY; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4091 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4092 |
synchronized (window.getTreeLock()) { |
30469 | 4093 |
WindowPeer peer = (WindowPeer) window.peer; |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4094 |
if (peer != null) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4095 |
peer.repositionSecurityWarning(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4096 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4097 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4098 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4099 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4100 |
public Point2D calculateSecurityWarningPosition(Window window, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4101 |
double x, double y, double w, double h) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4102 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4103 |
return window.calculateSecurityWarningPosition(x, y, w, h); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2459
diff
changeset
|
4104 |
} |
3084
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
2808
diff
changeset
|
4105 |
|
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
2808
diff
changeset
|
4106 |
public void setLWRequestStatus(Window changed, boolean status) { |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
2808
diff
changeset
|
4107 |
changed.syncLWRequests = status; |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
2808
diff
changeset
|
4108 |
} |
4371
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
4109 |
|
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
4110 |
public boolean isAutoRequestFocus(Window w) { |
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
4111 |
return w.autoRequestFocus; |
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
4112 |
} |
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
4113 |
|
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
4114 |
public boolean isTrayIconWindow(Window w) { |
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
4115 |
return w.isTrayIconWindow; |
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
4116 |
} |
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
4117 |
|
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
4118 |
public void setTrayIconWindow(Window w, boolean isTrayIconWindow) { |
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
4119 |
w.isTrayIconWindow = isTrayIconWindow; |
dc9dcb8b0ae7
6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents:
4366
diff
changeset
|
4120 |
} |
2451 | 4121 |
}); // WindowAccessor |
4122 |
} // static |
|
4123 |
||
2647
ea80a312972e
6825362: Avoid calling peer.setZOrder on Window instances
dcherepanov
parents:
2472
diff
changeset
|
4124 |
// a window doesn't need to be updated in the Z-order. |
ea80a312972e
6825362: Avoid calling peer.setZOrder on Window instances
dcherepanov
parents:
2472
diff
changeset
|
4125 |
@Override |
ea80a312972e
6825362: Avoid calling peer.setZOrder on Window instances
dcherepanov
parents:
2472
diff
changeset
|
4126 |
void updateZOrder() {} |
ea80a312972e
6825362: Avoid calling peer.setZOrder on Window instances
dcherepanov
parents:
2472
diff
changeset
|
4127 |
|
2 | 4128 |
} // class Window |
4129 |
||
4130 |
||
4131 |
/** |
|
4132 |
* This class is no longer used, but is maintained for Serialization |
|
4133 |
* backward-compatibility. |
|
4134 |
*/ |
|
4135 |
class FocusManager implements java.io.Serializable { |
|
4136 |
Container focusRoot; |
|
4137 |
Component focusOwner; |
|
4138 |
||
4139 |
/* |
|
4140 |
* JDK 1.1 serialVersionUID |
|
4141 |
*/ |
|
4142 |
static final long serialVersionUID = 2491878825643557906L; |
|
4143 |
} |