author | avstepan |
Thu, 26 Mar 2015 14:18:42 +0400 | |
changeset 29882 | d36e2fcc5f55 |
parent 27565 | 729f9700483a |
child 29886 | 545c0c3809b8 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
22282
cf7ce8b79a25
8031550: Fix overloads lint warnings in client code
darcy
parents:
22060
diff
changeset
|
2 |
* Copyright (c) 1995, 2014, 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 |
||
26 |
package java.awt; |
|
27 |
||
28 |
import java.beans.PropertyChangeEvent; |
|
29 |
import java.awt.event.*; |
|
30 |
import java.awt.peer.*; |
|
31 |
import java.awt.im.InputMethodHighlight; |
|
32 |
import java.awt.image.ImageObserver; |
|
33 |
import java.awt.image.ImageProducer; |
|
34 |
import java.awt.image.ColorModel; |
|
35 |
import java.awt.datatransfer.Clipboard; |
|
36 |
import java.awt.dnd.DragSource; |
|
37 |
import java.awt.dnd.DragGestureRecognizer; |
|
38 |
import java.awt.dnd.DragGestureEvent; |
|
39 |
import java.awt.dnd.DragGestureListener; |
|
40 |
import java.awt.dnd.InvalidDnDOperationException; |
|
41 |
import java.awt.dnd.peer.DragSourceContextPeer; |
|
42 |
import java.net.URL; |
|
43 |
import java.io.File; |
|
44 |
import java.io.FileInputStream; |
|
45 |
||
46 |
import java.util.*; |
|
47 |
import java.beans.PropertyChangeListener; |
|
48 |
import java.beans.PropertyChangeSupport; |
|
49 |
import sun.awt.AppContext; |
|
50 |
||
51 |
import sun.awt.HeadlessToolkit; |
|
52 |
import sun.awt.NullComponentPeer; |
|
53 |
import sun.awt.PeerEvent; |
|
54 |
import sun.awt.SunToolkit; |
|
20147
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
55 |
import sun.awt.AWTAccessor; |
22060
cd4f9d7dbeda
8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents:
21957
diff
changeset
|
56 |
import sun.awt.AWTPermissions; |
2 | 57 |
|
58 |
import sun.util.CoreResourceBundleControl; |
|
59 |
||
60 |
/** |
|
61 |
* This class is the abstract superclass of all actual |
|
62 |
* implementations of the Abstract Window Toolkit. Subclasses of |
|
63 |
* the <code>Toolkit</code> class are used to bind the various components |
|
64 |
* to particular native toolkit implementations. |
|
65 |
* <p> |
|
66 |
* Many GUI events may be delivered to user |
|
67 |
* asynchronously, if the opposite is not specified explicitly. |
|
68 |
* As well as |
|
69 |
* many GUI operations may be performed asynchronously. |
|
70 |
* This fact means that if the state of a component is set, and then |
|
71 |
* the state immediately queried, the returned value may not yet |
|
72 |
* reflect the requested change. This behavior includes, but is not |
|
73 |
* limited to: |
|
74 |
* <ul> |
|
75 |
* <li>Scrolling to a specified position. |
|
76 |
* <br>For example, calling <code>ScrollPane.setScrollPosition</code> |
|
77 |
* and then <code>getScrollPosition</code> may return an incorrect |
|
78 |
* value if the original request has not yet been processed. |
|
21957 | 79 |
* |
2 | 80 |
* <li>Moving the focus from one component to another. |
81 |
* <br>For more information, see |
|
20455
f6f9a0c2796b
8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents:
20154
diff
changeset
|
82 |
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html#transferTiming">Timing |
2 | 83 |
* Focus Transfers</a>, a section in |
84 |
* <a href="http://java.sun.com/docs/books/tutorial/uiswing/">The Swing |
|
85 |
* Tutorial</a>. |
|
21957 | 86 |
* |
2 | 87 |
* <li>Making a top-level container visible. |
88 |
* <br>Calling <code>setVisible(true)</code> on a <code>Window</code>, |
|
89 |
* <code>Frame</code> or <code>Dialog</code> may occur |
|
90 |
* asynchronously. |
|
21957 | 91 |
* |
2 | 92 |
* <li>Setting the size or location of a top-level container. |
93 |
* <br>Calls to <code>setSize</code>, <code>setBounds</code> or |
|
94 |
* <code>setLocation</code> on a <code>Window</code>, |
|
95 |
* <code>Frame</code> or <code>Dialog</code> are forwarded |
|
96 |
* to the underlying window management system and may be |
|
97 |
* ignored or modified. See {@link java.awt.Window} for |
|
98 |
* more information. |
|
99 |
* </ul> |
|
100 |
* <p> |
|
101 |
* Most applications should not call any of the methods in this |
|
102 |
* class directly. The methods defined by <code>Toolkit</code> are |
|
103 |
* the "glue" that joins the platform-independent classes in the |
|
104 |
* <code>java.awt</code> package with their counterparts in |
|
105 |
* <code>java.awt.peer</code>. Some methods defined by |
|
106 |
* <code>Toolkit</code> query the native operating system directly. |
|
107 |
* |
|
108 |
* @author Sami Shaio |
|
109 |
* @author Arthur van Hoff |
|
110 |
* @author Fred Ecks |
|
24865
09b1d992ca72
8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents:
23717
diff
changeset
|
111 |
* @since 1.0 |
2 | 112 |
*/ |
113 |
public abstract class Toolkit { |
|
114 |
||
115 |
/** |
|
116 |
* Creates this toolkit's implementation of the <code>Desktop</code> |
|
117 |
* using the specified peer interface. |
|
118 |
* @param target the desktop to be implemented |
|
119 |
* @return this toolkit's implementation of the <code>Desktop</code> |
|
120 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
121 |
* returns true |
|
122 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
123 |
* @see java.awt.Desktop |
|
124 |
* @see java.awt.peer.DesktopPeer |
|
125 |
* @since 1.6 |
|
126 |
*/ |
|
127 |
protected abstract DesktopPeer createDesktopPeer(Desktop target) |
|
128 |
throws HeadlessException; |
|
129 |
||
130 |
||
131 |
/** |
|
132 |
* Creates this toolkit's implementation of <code>Button</code> using |
|
133 |
* the specified peer interface. |
|
134 |
* @param target the button to be implemented. |
|
135 |
* @return this toolkit's implementation of <code>Button</code>. |
|
136 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
137 |
* returns true |
|
138 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
139 |
* @see java.awt.Button |
|
140 |
* @see java.awt.peer.ButtonPeer |
|
141 |
*/ |
|
142 |
protected abstract ButtonPeer createButton(Button target) |
|
143 |
throws HeadlessException; |
|
144 |
||
145 |
/** |
|
146 |
* Creates this toolkit's implementation of <code>TextField</code> using |
|
147 |
* the specified peer interface. |
|
148 |
* @param target the text field to be implemented. |
|
149 |
* @return this toolkit's implementation of <code>TextField</code>. |
|
150 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
151 |
* returns true |
|
152 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
153 |
* @see java.awt.TextField |
|
154 |
* @see java.awt.peer.TextFieldPeer |
|
155 |
*/ |
|
156 |
protected abstract TextFieldPeer createTextField(TextField target) |
|
157 |
throws HeadlessException; |
|
158 |
||
159 |
/** |
|
160 |
* Creates this toolkit's implementation of <code>Label</code> using |
|
161 |
* the specified peer interface. |
|
162 |
* @param target the label to be implemented. |
|
163 |
* @return this toolkit's implementation of <code>Label</code>. |
|
164 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
165 |
* returns true |
|
166 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
167 |
* @see java.awt.Label |
|
168 |
* @see java.awt.peer.LabelPeer |
|
169 |
*/ |
|
170 |
protected abstract LabelPeer createLabel(Label target) |
|
171 |
throws HeadlessException; |
|
172 |
||
173 |
/** |
|
174 |
* Creates this toolkit's implementation of <code>List</code> using |
|
175 |
* the specified peer interface. |
|
176 |
* @param target the list to be implemented. |
|
177 |
* @return this toolkit's implementation of <code>List</code>. |
|
178 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
179 |
* returns true |
|
180 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
181 |
* @see java.awt.List |
|
182 |
* @see java.awt.peer.ListPeer |
|
183 |
*/ |
|
184 |
protected abstract ListPeer createList(java.awt.List target) |
|
185 |
throws HeadlessException; |
|
186 |
||
187 |
/** |
|
188 |
* Creates this toolkit's implementation of <code>Checkbox</code> using |
|
189 |
* the specified peer interface. |
|
190 |
* @param target the check box to be implemented. |
|
191 |
* @return this toolkit's implementation of <code>Checkbox</code>. |
|
192 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
193 |
* returns true |
|
194 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
195 |
* @see java.awt.Checkbox |
|
196 |
* @see java.awt.peer.CheckboxPeer |
|
197 |
*/ |
|
198 |
protected abstract CheckboxPeer createCheckbox(Checkbox target) |
|
199 |
throws HeadlessException; |
|
200 |
||
201 |
/** |
|
202 |
* Creates this toolkit's implementation of <code>Scrollbar</code> using |
|
203 |
* the specified peer interface. |
|
204 |
* @param target the scroll bar to be implemented. |
|
205 |
* @return this toolkit's implementation of <code>Scrollbar</code>. |
|
206 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
207 |
* returns true |
|
208 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
209 |
* @see java.awt.Scrollbar |
|
210 |
* @see java.awt.peer.ScrollbarPeer |
|
211 |
*/ |
|
212 |
protected abstract ScrollbarPeer createScrollbar(Scrollbar target) |
|
213 |
throws HeadlessException; |
|
214 |
||
215 |
/** |
|
216 |
* Creates this toolkit's implementation of <code>ScrollPane</code> using |
|
217 |
* the specified peer interface. |
|
218 |
* @param target the scroll pane to be implemented. |
|
219 |
* @return this toolkit's implementation of <code>ScrollPane</code>. |
|
220 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
221 |
* returns true |
|
222 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
223 |
* @see java.awt.ScrollPane |
|
224 |
* @see java.awt.peer.ScrollPanePeer |
|
24865
09b1d992ca72
8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents:
23717
diff
changeset
|
225 |
* @since 1.1 |
2 | 226 |
*/ |
227 |
protected abstract ScrollPanePeer createScrollPane(ScrollPane target) |
|
228 |
throws HeadlessException; |
|
229 |
||
230 |
/** |
|
231 |
* Creates this toolkit's implementation of <code>TextArea</code> using |
|
232 |
* the specified peer interface. |
|
233 |
* @param target the text area to be implemented. |
|
234 |
* @return this toolkit's implementation of <code>TextArea</code>. |
|
235 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
236 |
* returns true |
|
237 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
238 |
* @see java.awt.TextArea |
|
239 |
* @see java.awt.peer.TextAreaPeer |
|
240 |
*/ |
|
241 |
protected abstract TextAreaPeer createTextArea(TextArea target) |
|
242 |
throws HeadlessException; |
|
243 |
||
244 |
/** |
|
245 |
* Creates this toolkit's implementation of <code>Choice</code> using |
|
246 |
* the specified peer interface. |
|
247 |
* @param target the choice to be implemented. |
|
248 |
* @return this toolkit's implementation of <code>Choice</code>. |
|
249 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
250 |
* returns true |
|
251 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
252 |
* @see java.awt.Choice |
|
253 |
* @see java.awt.peer.ChoicePeer |
|
254 |
*/ |
|
255 |
protected abstract ChoicePeer createChoice(Choice target) |
|
256 |
throws HeadlessException; |
|
257 |
||
258 |
/** |
|
259 |
* Creates this toolkit's implementation of <code>Frame</code> using |
|
260 |
* the specified peer interface. |
|
261 |
* @param target the frame to be implemented. |
|
262 |
* @return this toolkit's implementation of <code>Frame</code>. |
|
263 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
264 |
* returns true |
|
265 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
266 |
* @see java.awt.Frame |
|
267 |
* @see java.awt.peer.FramePeer |
|
268 |
*/ |
|
269 |
protected abstract FramePeer createFrame(Frame target) |
|
270 |
throws HeadlessException; |
|
271 |
||
272 |
/** |
|
273 |
* Creates this toolkit's implementation of <code>Canvas</code> using |
|
274 |
* the specified peer interface. |
|
275 |
* @param target the canvas to be implemented. |
|
276 |
* @return this toolkit's implementation of <code>Canvas</code>. |
|
277 |
* @see java.awt.Canvas |
|
278 |
* @see java.awt.peer.CanvasPeer |
|
279 |
*/ |
|
280 |
protected abstract CanvasPeer createCanvas(Canvas target); |
|
281 |
||
282 |
/** |
|
283 |
* Creates this toolkit's implementation of <code>Panel</code> using |
|
284 |
* the specified peer interface. |
|
285 |
* @param target the panel to be implemented. |
|
286 |
* @return this toolkit's implementation of <code>Panel</code>. |
|
287 |
* @see java.awt.Panel |
|
288 |
* @see java.awt.peer.PanelPeer |
|
289 |
*/ |
|
290 |
protected abstract PanelPeer createPanel(Panel target); |
|
291 |
||
292 |
/** |
|
293 |
* Creates this toolkit's implementation of <code>Window</code> using |
|
294 |
* the specified peer interface. |
|
295 |
* @param target the window to be implemented. |
|
296 |
* @return this toolkit's implementation of <code>Window</code>. |
|
297 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
298 |
* returns true |
|
299 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
300 |
* @see java.awt.Window |
|
301 |
* @see java.awt.peer.WindowPeer |
|
302 |
*/ |
|
303 |
protected abstract WindowPeer createWindow(Window target) |
|
304 |
throws HeadlessException; |
|
305 |
||
306 |
/** |
|
307 |
* Creates this toolkit's implementation of <code>Dialog</code> using |
|
308 |
* the specified peer interface. |
|
309 |
* @param target the dialog to be implemented. |
|
310 |
* @return this toolkit's implementation of <code>Dialog</code>. |
|
311 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
312 |
* returns true |
|
313 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
314 |
* @see java.awt.Dialog |
|
315 |
* @see java.awt.peer.DialogPeer |
|
316 |
*/ |
|
317 |
protected abstract DialogPeer createDialog(Dialog target) |
|
318 |
throws HeadlessException; |
|
319 |
||
320 |
/** |
|
321 |
* Creates this toolkit's implementation of <code>MenuBar</code> using |
|
322 |
* the specified peer interface. |
|
323 |
* @param target the menu bar to be implemented. |
|
324 |
* @return this toolkit's implementation of <code>MenuBar</code>. |
|
325 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
326 |
* returns true |
|
327 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
328 |
* @see java.awt.MenuBar |
|
329 |
* @see java.awt.peer.MenuBarPeer |
|
330 |
*/ |
|
331 |
protected abstract MenuBarPeer createMenuBar(MenuBar target) |
|
332 |
throws HeadlessException; |
|
333 |
||
334 |
/** |
|
335 |
* Creates this toolkit's implementation of <code>Menu</code> using |
|
336 |
* the specified peer interface. |
|
337 |
* @param target the menu to be implemented. |
|
338 |
* @return this toolkit's implementation of <code>Menu</code>. |
|
339 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
340 |
* returns true |
|
341 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
342 |
* @see java.awt.Menu |
|
343 |
* @see java.awt.peer.MenuPeer |
|
344 |
*/ |
|
345 |
protected abstract MenuPeer createMenu(Menu target) |
|
346 |
throws HeadlessException; |
|
347 |
||
348 |
/** |
|
349 |
* Creates this toolkit's implementation of <code>PopupMenu</code> using |
|
350 |
* the specified peer interface. |
|
351 |
* @param target the popup menu to be implemented. |
|
352 |
* @return this toolkit's implementation of <code>PopupMenu</code>. |
|
353 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
354 |
* returns true |
|
355 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
356 |
* @see java.awt.PopupMenu |
|
357 |
* @see java.awt.peer.PopupMenuPeer |
|
24865
09b1d992ca72
8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents:
23717
diff
changeset
|
358 |
* @since 1.1 |
2 | 359 |
*/ |
360 |
protected abstract PopupMenuPeer createPopupMenu(PopupMenu target) |
|
361 |
throws HeadlessException; |
|
362 |
||
363 |
/** |
|
364 |
* Creates this toolkit's implementation of <code>MenuItem</code> using |
|
365 |
* the specified peer interface. |
|
366 |
* @param target the menu item to be implemented. |
|
367 |
* @return this toolkit's implementation of <code>MenuItem</code>. |
|
368 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
369 |
* returns true |
|
370 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
371 |
* @see java.awt.MenuItem |
|
372 |
* @see java.awt.peer.MenuItemPeer |
|
373 |
*/ |
|
374 |
protected abstract MenuItemPeer createMenuItem(MenuItem target) |
|
375 |
throws HeadlessException; |
|
376 |
||
377 |
/** |
|
378 |
* Creates this toolkit's implementation of <code>FileDialog</code> using |
|
379 |
* the specified peer interface. |
|
380 |
* @param target the file dialog to be implemented. |
|
381 |
* @return this toolkit's implementation of <code>FileDialog</code>. |
|
382 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
383 |
* returns true |
|
384 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
385 |
* @see java.awt.FileDialog |
|
386 |
* @see java.awt.peer.FileDialogPeer |
|
387 |
*/ |
|
388 |
protected abstract FileDialogPeer createFileDialog(FileDialog target) |
|
389 |
throws HeadlessException; |
|
390 |
||
391 |
/** |
|
392 |
* Creates this toolkit's implementation of <code>CheckboxMenuItem</code> using |
|
393 |
* the specified peer interface. |
|
394 |
* @param target the checkbox menu item to be implemented. |
|
395 |
* @return this toolkit's implementation of <code>CheckboxMenuItem</code>. |
|
396 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
397 |
* returns true |
|
398 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
399 |
* @see java.awt.CheckboxMenuItem |
|
400 |
* @see java.awt.peer.CheckboxMenuItemPeer |
|
401 |
*/ |
|
402 |
protected abstract CheckboxMenuItemPeer createCheckboxMenuItem( |
|
403 |
CheckboxMenuItem target) throws HeadlessException; |
|
404 |
||
405 |
/** |
|
406 |
* Obtains this toolkit's implementation of helper class for |
|
407 |
* <code>MouseInfo</code> operations. |
|
408 |
* @return this toolkit's implementation of helper for <code>MouseInfo</code> |
|
409 |
* @throws UnsupportedOperationException if this operation is not implemented |
|
410 |
* @see java.awt.peer.MouseInfoPeer |
|
411 |
* @see java.awt.MouseInfo |
|
412 |
* @since 1.5 |
|
413 |
*/ |
|
414 |
protected MouseInfoPeer getMouseInfoPeer() { |
|
415 |
throw new UnsupportedOperationException("Not implemented"); |
|
416 |
} |
|
417 |
||
418 |
private static LightweightPeer lightweightMarker; |
|
419 |
||
420 |
/** |
|
421 |
* Creates a peer for a component or container. This peer is windowless |
|
422 |
* and allows the Component and Container classes to be extended directly |
|
423 |
* to create windowless components that are defined entirely in java. |
|
424 |
* |
|
25162 | 425 |
* @param target The Component to be created. |
426 |
* @return the peer for the specified component |
|
2 | 427 |
*/ |
428 |
protected LightweightPeer createComponent(Component target) { |
|
429 |
if (lightweightMarker == null) { |
|
430 |
lightweightMarker = new NullComponentPeer(); |
|
431 |
} |
|
432 |
return lightweightMarker; |
|
433 |
} |
|
434 |
||
435 |
/** |
|
436 |
* Creates this toolkit's implementation of <code>Font</code> using |
|
437 |
* the specified peer interface. |
|
438 |
* @param name the font to be implemented |
|
439 |
* @param style the style of the font, such as <code>PLAIN</code>, |
|
440 |
* <code>BOLD</code>, <code>ITALIC</code>, or a combination |
|
441 |
* @return this toolkit's implementation of <code>Font</code> |
|
442 |
* @see java.awt.Font |
|
443 |
* @see java.awt.peer.FontPeer |
|
444 |
* @see java.awt.GraphicsEnvironment#getAllFonts |
|
445 |
* @deprecated see java.awt.GraphicsEnvironment#getAllFonts |
|
446 |
*/ |
|
447 |
@Deprecated |
|
448 |
protected abstract FontPeer getFontPeer(String name, int style); |
|
449 |
||
450 |
// The following method is called by the private method |
|
451 |
// <code>updateSystemColors</code> in <code>SystemColor</code>. |
|
452 |
||
453 |
/** |
|
454 |
* Fills in the integer array that is supplied as an argument |
|
455 |
* with the current system color values. |
|
456 |
* |
|
457 |
* @param systemColors an integer array. |
|
458 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
459 |
* returns true |
|
460 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
24865
09b1d992ca72
8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents:
23717
diff
changeset
|
461 |
* @since 1.1 |
2 | 462 |
*/ |
463 |
protected void loadSystemColors(int[] systemColors) |
|
464 |
throws HeadlessException { |
|
9656
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
465 |
GraphicsEnvironment.checkHeadless(); |
2 | 466 |
} |
467 |
||
20154
551a86159e69
7172833: For default java.awt.Toolkit impl methods java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
20147
diff
changeset
|
468 |
/** |
2 | 469 |
* Controls whether the layout of Containers is validated dynamically |
470 |
* during resizing, or statically, after resizing is complete. |
|
471 |
* Use {@code isDynamicLayoutActive()} to detect if this feature enabled |
|
472 |
* in this program and is supported by this operating system |
|
473 |
* and/or window manager. |
|
474 |
* Note that this feature is supported not on all platforms, and |
|
475 |
* conversely, that this feature cannot be turned off on some platforms. |
|
476 |
* On these platforms where dynamic layout during resizing is not supported |
|
477 |
* (or is always supported), setting this property has no effect. |
|
478 |
* Note that this feature can be set or unset as a property of the |
|
479 |
* operating system or window manager on some platforms. On such |
|
480 |
* platforms, the dynamic resize property must be set at the operating |
|
481 |
* system or window manager level before this method can take effect. |
|
482 |
* This method does not change support or settings of the underlying |
|
483 |
* operating system or |
|
484 |
* window manager. The OS/WM support can be |
|
485 |
* queried using getDesktopProperty("awt.dynamicLayoutSupported") method. |
|
486 |
* |
|
487 |
* @param dynamic If true, Containers should re-layout their |
|
488 |
* components as the Container is being resized. If false, |
|
489 |
* the layout will be validated after resizing is completed. |
|
490 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
491 |
* returns true |
|
492 |
* @see #isDynamicLayoutSet() |
|
493 |
* @see #isDynamicLayoutActive() |
|
494 |
* @see #getDesktopProperty(String propertyName) |
|
495 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
496 |
* @since 1.4 |
|
497 |
*/ |
|
20154
551a86159e69
7172833: For default java.awt.Toolkit impl methods java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
20147
diff
changeset
|
498 |
public void setDynamicLayout(final boolean dynamic) |
2 | 499 |
throws HeadlessException { |
9656
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
500 |
GraphicsEnvironment.checkHeadless(); |
20154
551a86159e69
7172833: For default java.awt.Toolkit impl methods java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
20147
diff
changeset
|
501 |
if (this != getDefaultToolkit()) { |
551a86159e69
7172833: For default java.awt.Toolkit impl methods java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
20147
diff
changeset
|
502 |
getDefaultToolkit().setDynamicLayout(dynamic); |
551a86159e69
7172833: For default java.awt.Toolkit impl methods java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
20147
diff
changeset
|
503 |
} |
2 | 504 |
} |
505 |
||
506 |
/** |
|
507 |
* Returns whether the layout of Containers is validated dynamically |
|
508 |
* during resizing, or statically, after resizing is complete. |
|
509 |
* Note: this method returns the value that was set programmatically; |
|
510 |
* it does not reflect support at the level of the operating system |
|
511 |
* or window manager for dynamic layout on resizing, or the current |
|
512 |
* operating system or window manager settings. The OS/WM support can |
|
513 |
* be queried using getDesktopProperty("awt.dynamicLayoutSupported"). |
|
514 |
* |
|
515 |
* @return true if validation of Containers is done dynamically, |
|
516 |
* false if validation is done after resizing is finished. |
|
517 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
518 |
* returns true |
|
519 |
* @see #setDynamicLayout(boolean dynamic) |
|
520 |
* @see #isDynamicLayoutActive() |
|
521 |
* @see #getDesktopProperty(String propertyName) |
|
522 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
523 |
* @since 1.4 |
|
524 |
*/ |
|
525 |
protected boolean isDynamicLayoutSet() |
|
526 |
throws HeadlessException { |
|
9656
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
527 |
GraphicsEnvironment.checkHeadless(); |
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
528 |
|
2 | 529 |
if (this != Toolkit.getDefaultToolkit()) { |
530 |
return Toolkit.getDefaultToolkit().isDynamicLayoutSet(); |
|
531 |
} else { |
|
532 |
return false; |
|
533 |
} |
|
534 |
} |
|
535 |
||
536 |
/** |
|
537 |
* Returns whether dynamic layout of Containers on resize is |
|
538 |
* currently active (both set in program |
|
539 |
*( {@code isDynamicLayoutSet()} ) |
|
540 |
*, and supported |
|
541 |
* by the underlying operating system and/or window manager). |
|
542 |
* If dynamic layout is currently inactive then Containers |
|
543 |
* re-layout their components when resizing is completed. As a result |
|
544 |
* the {@code Component.validate()} method will be invoked only |
|
545 |
* once per resize. |
|
546 |
* If dynamic layout is currently active then Containers |
|
547 |
* re-layout their components on every native resize event and |
|
548 |
* the {@code validate()} method will be invoked each time. |
|
549 |
* The OS/WM support can be queried using |
|
550 |
* the getDesktopProperty("awt.dynamicLayoutSupported") method. |
|
551 |
* |
|
552 |
* @return true if dynamic layout of Containers on resize is |
|
553 |
* currently active, false otherwise. |
|
554 |
* @exception HeadlessException if the GraphicsEnvironment.isHeadless() |
|
555 |
* method returns true |
|
556 |
* @see #setDynamicLayout(boolean dynamic) |
|
557 |
* @see #isDynamicLayoutSet() |
|
558 |
* @see #getDesktopProperty(String propertyName) |
|
559 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
560 |
* @since 1.4 |
|
561 |
*/ |
|
562 |
public boolean isDynamicLayoutActive() |
|
563 |
throws HeadlessException { |
|
9656
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
564 |
GraphicsEnvironment.checkHeadless(); |
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
565 |
|
2 | 566 |
if (this != Toolkit.getDefaultToolkit()) { |
567 |
return Toolkit.getDefaultToolkit().isDynamicLayoutActive(); |
|
568 |
} else { |
|
569 |
return false; |
|
570 |
} |
|
571 |
} |
|
572 |
||
573 |
/** |
|
574 |
* Gets the size of the screen. On systems with multiple displays, the |
|
575 |
* primary display is used. Multi-screen aware display dimensions are |
|
576 |
* available from <code>GraphicsConfiguration</code> and |
|
577 |
* <code>GraphicsDevice</code>. |
|
578 |
* @return the size of this toolkit's screen, in pixels. |
|
579 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
580 |
* returns true |
|
581 |
* @see java.awt.GraphicsConfiguration#getBounds |
|
582 |
* @see java.awt.GraphicsDevice#getDisplayMode |
|
583 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
584 |
*/ |
|
585 |
public abstract Dimension getScreenSize() |
|
586 |
throws HeadlessException; |
|
587 |
||
588 |
/** |
|
589 |
* Returns the screen resolution in dots-per-inch. |
|
590 |
* @return this toolkit's screen resolution, in dots-per-inch. |
|
591 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
592 |
* returns true |
|
593 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
594 |
*/ |
|
595 |
public abstract int getScreenResolution() |
|
596 |
throws HeadlessException; |
|
597 |
||
598 |
/** |
|
599 |
* Gets the insets of the screen. |
|
600 |
* @param gc a <code>GraphicsConfiguration</code> |
|
601 |
* @return the insets of this toolkit's screen, in pixels. |
|
602 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
603 |
* returns true |
|
604 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
605 |
* @since 1.4 |
|
606 |
*/ |
|
607 |
public Insets getScreenInsets(GraphicsConfiguration gc) |
|
608 |
throws HeadlessException { |
|
9656
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
609 |
GraphicsEnvironment.checkHeadless(); |
2 | 610 |
if (this != Toolkit.getDefaultToolkit()) { |
611 |
return Toolkit.getDefaultToolkit().getScreenInsets(gc); |
|
612 |
} else { |
|
613 |
return new Insets(0, 0, 0, 0); |
|
614 |
} |
|
615 |
} |
|
616 |
||
617 |
/** |
|
618 |
* Determines the color model of this toolkit's screen. |
|
619 |
* <p> |
|
620 |
* <code>ColorModel</code> is an abstract class that |
|
621 |
* encapsulates the ability to translate between the |
|
622 |
* pixel values of an image and its red, green, blue, |
|
623 |
* and alpha components. |
|
624 |
* <p> |
|
625 |
* This toolkit method is called by the |
|
626 |
* <code>getColorModel</code> method |
|
627 |
* of the <code>Component</code> class. |
|
628 |
* @return the color model of this toolkit's screen. |
|
629 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
630 |
* returns true |
|
631 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
632 |
* @see java.awt.image.ColorModel |
|
633 |
* @see java.awt.Component#getColorModel |
|
634 |
*/ |
|
635 |
public abstract ColorModel getColorModel() |
|
636 |
throws HeadlessException; |
|
637 |
||
638 |
/** |
|
639 |
* Returns the names of the available fonts in this toolkit.<p> |
|
640 |
* For 1.1, the following font names are deprecated (the replacement |
|
641 |
* name follows): |
|
642 |
* <ul> |
|
643 |
* <li>TimesRoman (use Serif) |
|
644 |
* <li>Helvetica (use SansSerif) |
|
645 |
* <li>Courier (use Monospaced) |
|
646 |
* </ul><p> |
|
647 |
* The ZapfDingbats fontname is also deprecated in 1.1 but the characters |
|
648 |
* are defined in Unicode starting at 0x2700, and as of 1.1 Java supports |
|
649 |
* those characters. |
|
650 |
* @return the names of the available fonts in this toolkit. |
|
651 |
* @deprecated see {@link java.awt.GraphicsEnvironment#getAvailableFontFamilyNames()} |
|
652 |
* @see java.awt.GraphicsEnvironment#getAvailableFontFamilyNames() |
|
653 |
*/ |
|
654 |
@Deprecated |
|
655 |
public abstract String[] getFontList(); |
|
656 |
||
657 |
/** |
|
658 |
* Gets the screen device metrics for rendering of the font. |
|
659 |
* @param font a font |
|
660 |
* @return the screen metrics of the specified font in this toolkit |
|
661 |
* @deprecated As of JDK version 1.2, replaced by the <code>Font</code> |
|
662 |
* method <code>getLineMetrics</code>. |
|
663 |
* @see java.awt.font.LineMetrics |
|
664 |
* @see java.awt.Font#getLineMetrics |
|
665 |
* @see java.awt.GraphicsEnvironment#getScreenDevices |
|
666 |
*/ |
|
667 |
@Deprecated |
|
668 |
public abstract FontMetrics getFontMetrics(Font font); |
|
669 |
||
670 |
/** |
|
671 |
* Synchronizes this toolkit's graphics state. Some window systems |
|
672 |
* may do buffering of graphics events. |
|
673 |
* <p> |
|
674 |
* This method ensures that the display is up-to-date. It is useful |
|
675 |
* for animation. |
|
676 |
*/ |
|
677 |
public abstract void sync(); |
|
678 |
||
679 |
/** |
|
680 |
* The default toolkit. |
|
681 |
*/ |
|
682 |
private static Toolkit toolkit; |
|
683 |
||
684 |
/** |
|
685 |
* Used internally by the assistive technologies functions; set at |
|
686 |
* init time and used at load time |
|
687 |
*/ |
|
688 |
private static String atNames; |
|
689 |
||
690 |
/** |
|
691 |
* Initializes properties related to assistive technologies. |
|
692 |
* These properties are used both in the loadAssistiveProperties() |
|
693 |
* function below, as well as other classes in the jdk that depend |
|
694 |
* on the properties (such as the use of the screen_magnifier_present |
|
695 |
* property in Java2D hardware acceleration initialization). The |
|
696 |
* initialization of the properties must be done before the platform- |
|
697 |
* specific Toolkit class is instantiated so that all necessary |
|
698 |
* properties are set up properly before any classes dependent upon them |
|
699 |
* are initialized. |
|
700 |
*/ |
|
701 |
private static void initAssistiveTechnologies() { |
|
702 |
||
703 |
// Get accessibility properties |
|
704 |
final String sep = File.separator; |
|
705 |
final Properties properties = new Properties(); |
|
706 |
||
707 |
||
11270
d7b0b63bd082
7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents:
10068
diff
changeset
|
708 |
atNames = java.security.AccessController.doPrivileged( |
d7b0b63bd082
7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents:
10068
diff
changeset
|
709 |
new java.security.PrivilegedAction<String>() { |
d7b0b63bd082
7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents:
10068
diff
changeset
|
710 |
public String run() { |
2 | 711 |
|
712 |
// Try loading the per-user accessibility properties file. |
|
713 |
try { |
|
714 |
File propsFile = new File( |
|
715 |
System.getProperty("user.home") + |
|
716 |
sep + ".accessibility.properties"); |
|
717 |
FileInputStream in = |
|
718 |
new FileInputStream(propsFile); |
|
719 |
||
720 |
// Inputstream has been buffered in Properties class |
|
721 |
properties.load(in); |
|
722 |
in.close(); |
|
723 |
} catch (Exception e) { |
|
724 |
// Per-user accessibility properties file does not exist |
|
725 |
} |
|
726 |
||
727 |
// Try loading the system-wide accessibility properties |
|
728 |
// file only if a per-user accessibility properties |
|
729 |
// file does not exist or is empty. |
|
730 |
if (properties.size() == 0) { |
|
731 |
try { |
|
732 |
File propsFile = new File( |
|
27565 | 733 |
System.getProperty("java.home") + sep + "conf" + |
2 | 734 |
sep + "accessibility.properties"); |
735 |
FileInputStream in = |
|
736 |
new FileInputStream(propsFile); |
|
737 |
||
738 |
// Inputstream has been buffered in Properties class |
|
739 |
properties.load(in); |
|
740 |
in.close(); |
|
741 |
} catch (Exception e) { |
|
742 |
// System-wide accessibility properties file does |
|
743 |
// not exist; |
|
744 |
} |
|
745 |
} |
|
746 |
||
747 |
// Get whether a screen magnifier is present. First check |
|
748 |
// the system property and then check the properties file. |
|
749 |
String magPresent = System.getProperty("javax.accessibility.screen_magnifier_present"); |
|
750 |
if (magPresent == null) { |
|
751 |
magPresent = properties.getProperty("screen_magnifier_present", null); |
|
752 |
if (magPresent != null) { |
|
753 |
System.setProperty("javax.accessibility.screen_magnifier_present", magPresent); |
|
754 |
} |
|
755 |
} |
|
756 |
||
757 |
// Get the names of any assistive technolgies to load. First |
|
758 |
// check the system property and then check the properties |
|
759 |
// file. |
|
760 |
String classNames = System.getProperty("javax.accessibility.assistive_technologies"); |
|
761 |
if (classNames == null) { |
|
762 |
classNames = properties.getProperty("assistive_technologies", null); |
|
763 |
if (classNames != null) { |
|
764 |
System.setProperty("javax.accessibility.assistive_technologies", classNames); |
|
765 |
} |
|
766 |
} |
|
767 |
return classNames; |
|
768 |
} |
|
769 |
}); |
|
770 |
} |
|
771 |
||
772 |
/** |
|
773 |
* Loads additional classes into the VM, using the property |
|
774 |
* 'assistive_technologies' specified in the Sun reference |
|
775 |
* implementation by a line in the 'accessibility.properties' |
|
776 |
* file. The form is "assistive_technologies=..." where |
|
777 |
* the "..." is a comma-separated list of assistive technology |
|
778 |
* classes to load. Each class is loaded in the order given |
|
779 |
* and a single instance of each is created using |
|
780 |
* Class.forName(class).newInstance(). All errors are handled |
|
781 |
* via an AWTError exception. |
|
782 |
* |
|
783 |
* <p>The assumption is made that assistive technology classes are supplied |
|
784 |
* as part of INSTALLED (as opposed to: BUNDLED) extensions or specified |
|
785 |
* on the class path |
|
786 |
* (and therefore can be loaded using the class loader returned by |
|
787 |
* a call to <code>ClassLoader.getSystemClassLoader</code>, whose |
|
788 |
* delegation parent is the extension class loader for installed |
|
789 |
* extensions). |
|
790 |
*/ |
|
791 |
private static void loadAssistiveTechnologies() { |
|
792 |
// Load any assistive technologies |
|
793 |
if (atNames != null) { |
|
794 |
ClassLoader cl = ClassLoader.getSystemClassLoader(); |
|
795 |
StringTokenizer parser = new StringTokenizer(atNames," ,"); |
|
796 |
String atName; |
|
797 |
while (parser.hasMoreTokens()) { |
|
798 |
atName = parser.nextToken(); |
|
799 |
try { |
|
11270
d7b0b63bd082
7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents:
10068
diff
changeset
|
800 |
Class<?> clazz; |
2 | 801 |
if (cl != null) { |
802 |
clazz = cl.loadClass(atName); |
|
803 |
} else { |
|
804 |
clazz = Class.forName(atName); |
|
805 |
} |
|
806 |
clazz.newInstance(); |
|
807 |
} catch (ClassNotFoundException e) { |
|
808 |
throw new AWTError("Assistive Technology not found: " |
|
809 |
+ atName); |
|
810 |
} catch (InstantiationException e) { |
|
811 |
throw new AWTError("Could not instantiate Assistive" |
|
812 |
+ " Technology: " + atName); |
|
813 |
} catch (IllegalAccessException e) { |
|
814 |
throw new AWTError("Could not access Assistive" |
|
815 |
+ " Technology: " + atName); |
|
816 |
} catch (Exception e) { |
|
817 |
throw new AWTError("Error trying to install Assistive" |
|
818 |
+ " Technology: " + atName + " " + e); |
|
819 |
} |
|
820 |
} |
|
821 |
} |
|
822 |
} |
|
823 |
||
824 |
/** |
|
825 |
* Gets the default toolkit. |
|
826 |
* <p> |
|
827 |
* If a system property named <code>"java.awt.headless"</code> is set |
|
828 |
* to <code>true</code> then the headless implementation |
|
829 |
* of <code>Toolkit</code> is used. |
|
830 |
* <p> |
|
831 |
* If there is no <code>"java.awt.headless"</code> or it is set to |
|
832 |
* <code>false</code> and there is a system property named |
|
833 |
* <code>"awt.toolkit"</code>, |
|
834 |
* that property is treated as the name of a class that is a subclass |
|
835 |
* of <code>Toolkit</code>; |
|
836 |
* otherwise the default platform-specific implementation of |
|
837 |
* <code>Toolkit</code> is used. |
|
838 |
* <p> |
|
839 |
* Also loads additional classes into the VM, using the property |
|
840 |
* 'assistive_technologies' specified in the Sun reference |
|
841 |
* implementation by a line in the 'accessibility.properties' |
|
842 |
* file. The form is "assistive_technologies=..." where |
|
843 |
* the "..." is a comma-separated list of assistive technology |
|
844 |
* classes to load. Each class is loaded in the order given |
|
845 |
* and a single instance of each is created using |
|
846 |
* Class.forName(class).newInstance(). This is done just after |
|
847 |
* the AWT toolkit is created. All errors are handled via an |
|
848 |
* AWTError exception. |
|
849 |
* @return the default toolkit. |
|
850 |
* @exception AWTError if a toolkit could not be found, or |
|
851 |
* if one could not be accessed or instantiated. |
|
852 |
*/ |
|
853 |
public static synchronized Toolkit getDefaultToolkit() { |
|
854 |
if (toolkit == null) { |
|
23317
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
855 |
java.security.AccessController.doPrivileged( |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
856 |
new java.security.PrivilegedAction<Void>() { |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
857 |
public Void run() { |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
858 |
Class<?> cls = null; |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
859 |
String nm = System.getProperty("awt.toolkit"); |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
860 |
try { |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
861 |
cls = Class.forName(nm); |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
862 |
} catch (ClassNotFoundException e) { |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
863 |
ClassLoader cl = ClassLoader.getSystemClassLoader(); |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
864 |
if (cl != null) { |
2 | 865 |
try { |
23317
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
866 |
cls = cl.loadClass(nm); |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
867 |
} catch (final ClassNotFoundException ignored) { |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
868 |
throw new AWTError("Toolkit not found: " + nm); |
2 | 869 |
} |
23317
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
870 |
} |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
871 |
} |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
872 |
try { |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
873 |
if (cls != null) { |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
874 |
toolkit = (Toolkit)cls.newInstance(); |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
875 |
if (GraphicsEnvironment.isHeadless()) { |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
876 |
toolkit = new HeadlessToolkit(toolkit); |
2 | 877 |
} |
878 |
} |
|
23317
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
879 |
} catch (final InstantiationException ignored) { |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
880 |
throw new AWTError("Could not instantiate Toolkit: " + nm); |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
881 |
} catch (final IllegalAccessException ignored) { |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
882 |
throw new AWTError("Could not access Toolkit: " + nm); |
2 | 883 |
} |
23317
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
884 |
return null; |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
885 |
} |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
886 |
}); |
73a0f3327dcc
6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents:
22282
diff
changeset
|
887 |
loadAssistiveTechnologies(); |
2 | 888 |
} |
889 |
return toolkit; |
|
890 |
} |
|
891 |
||
892 |
/** |
|
893 |
* Returns an image which gets pixel data from the specified file, |
|
894 |
* whose format can be either GIF, JPEG or PNG. |
|
895 |
* The underlying toolkit attempts to resolve multiple requests |
|
896 |
* with the same filename to the same returned Image. |
|
897 |
* <p> |
|
898 |
* Since the mechanism required to facilitate this sharing of |
|
899 |
* <code>Image</code> objects may continue to hold onto images |
|
900 |
* that are no longer in use for an indefinite period of time, |
|
901 |
* developers are encouraged to implement their own caching of |
|
902 |
* images by using the {@link #createImage(java.lang.String) createImage} |
|
903 |
* variant wherever available. |
|
904 |
* If the image data contained in the specified file changes, |
|
905 |
* the <code>Image</code> object returned from this method may |
|
906 |
* still contain stale information which was loaded from the |
|
907 |
* file after a prior call. |
|
908 |
* Previously loaded image data can be manually discarded by |
|
909 |
* calling the {@link Image#flush flush} method on the |
|
910 |
* returned <code>Image</code>. |
|
911 |
* <p> |
|
912 |
* This method first checks if there is a security manager installed. |
|
913 |
* If so, the method calls the security manager's |
|
914 |
* <code>checkRead</code> method with the file specified to ensure |
|
915 |
* that the access to the image is allowed. |
|
916 |
* @param filename the name of a file containing pixel data |
|
917 |
* in a recognized file format. |
|
918 |
* @return an image which gets its pixel data from |
|
919 |
* the specified file. |
|
920 |
* @throws SecurityException if a security manager exists and its |
|
921 |
* checkRead method doesn't allow the operation. |
|
922 |
* @see #createImage(java.lang.String) |
|
923 |
*/ |
|
924 |
public abstract Image getImage(String filename); |
|
925 |
||
926 |
/** |
|
927 |
* Returns an image which gets pixel data from the specified URL. |
|
928 |
* The pixel data referenced by the specified URL must be in one |
|
929 |
* of the following formats: GIF, JPEG or PNG. |
|
930 |
* The underlying toolkit attempts to resolve multiple requests |
|
931 |
* with the same URL to the same returned Image. |
|
932 |
* <p> |
|
933 |
* Since the mechanism required to facilitate this sharing of |
|
934 |
* <code>Image</code> objects may continue to hold onto images |
|
935 |
* that are no longer in use for an indefinite period of time, |
|
936 |
* developers are encouraged to implement their own caching of |
|
937 |
* images by using the {@link #createImage(java.net.URL) createImage} |
|
938 |
* variant wherever available. |
|
939 |
* If the image data stored at the specified URL changes, |
|
940 |
* the <code>Image</code> object returned from this method may |
|
941 |
* still contain stale information which was fetched from the |
|
942 |
* URL after a prior call. |
|
943 |
* Previously loaded image data can be manually discarded by |
|
944 |
* calling the {@link Image#flush flush} method on the |
|
945 |
* returned <code>Image</code>. |
|
946 |
* <p> |
|
947 |
* This method first checks if there is a security manager installed. |
|
948 |
* If so, the method calls the security manager's |
|
949 |
* <code>checkPermission</code> method with the |
|
950 |
* url.openConnection().getPermission() permission to ensure |
|
951 |
* that the access to the image is allowed. For compatibility |
|
952 |
* with pre-1.2 security managers, if the access is denied with |
|
953 |
* <code>FilePermission</code> or <code>SocketPermission</code>, |
|
954 |
* the method throws the <code>SecurityException</code> |
|
955 |
* if the corresponding 1.1-style SecurityManager.checkXXX method |
|
956 |
* also denies permission. |
|
957 |
* @param url the URL to use in fetching the pixel data. |
|
958 |
* @return an image which gets its pixel data from |
|
959 |
* the specified URL. |
|
960 |
* @throws SecurityException if a security manager exists and its |
|
961 |
* checkPermission method doesn't allow |
|
962 |
* the operation. |
|
963 |
* @see #createImage(java.net.URL) |
|
964 |
*/ |
|
965 |
public abstract Image getImage(URL url); |
|
966 |
||
967 |
/** |
|
968 |
* Returns an image which gets pixel data from the specified file. |
|
969 |
* The returned Image is a new object which will not be shared |
|
970 |
* with any other caller of this method or its getImage variant. |
|
971 |
* <p> |
|
972 |
* This method first checks if there is a security manager installed. |
|
973 |
* If so, the method calls the security manager's |
|
974 |
* <code>checkRead</code> method with the specified file to ensure |
|
975 |
* that the image creation is allowed. |
|
976 |
* @param filename the name of a file containing pixel data |
|
977 |
* in a recognized file format. |
|
978 |
* @return an image which gets its pixel data from |
|
979 |
* the specified file. |
|
980 |
* @throws SecurityException if a security manager exists and its |
|
981 |
* checkRead method doesn't allow the operation. |
|
982 |
* @see #getImage(java.lang.String) |
|
983 |
*/ |
|
984 |
public abstract Image createImage(String filename); |
|
985 |
||
986 |
/** |
|
987 |
* Returns an image which gets pixel data from the specified URL. |
|
988 |
* The returned Image is a new object which will not be shared |
|
989 |
* with any other caller of this method or its getImage variant. |
|
990 |
* <p> |
|
991 |
* This method first checks if there is a security manager installed. |
|
992 |
* If so, the method calls the security manager's |
|
993 |
* <code>checkPermission</code> method with the |
|
994 |
* url.openConnection().getPermission() permission to ensure |
|
995 |
* that the image creation is allowed. For compatibility |
|
996 |
* with pre-1.2 security managers, if the access is denied with |
|
997 |
* <code>FilePermission</code> or <code>SocketPermission</code>, |
|
998 |
* the method throws <code>SecurityException</code> |
|
999 |
* if the corresponding 1.1-style SecurityManager.checkXXX method |
|
1000 |
* also denies permission. |
|
1001 |
* @param url the URL to use in fetching the pixel data. |
|
1002 |
* @return an image which gets its pixel data from |
|
1003 |
* the specified URL. |
|
1004 |
* @throws SecurityException if a security manager exists and its |
|
1005 |
* checkPermission method doesn't allow |
|
1006 |
* the operation. |
|
1007 |
* @see #getImage(java.net.URL) |
|
1008 |
*/ |
|
1009 |
public abstract Image createImage(URL url); |
|
1010 |
||
1011 |
/** |
|
1012 |
* Prepares an image for rendering. |
|
1013 |
* <p> |
|
1014 |
* If the values of the width and height arguments are both |
|
1015 |
* <code>-1</code>, this method prepares the image for rendering |
|
1016 |
* on the default screen; otherwise, this method prepares an image |
|
1017 |
* for rendering on the default screen at the specified width and height. |
|
1018 |
* <p> |
|
1019 |
* The image data is downloaded asynchronously in another thread, |
|
1020 |
* and an appropriately scaled screen representation of the image is |
|
1021 |
* generated. |
|
1022 |
* <p> |
|
1023 |
* This method is called by components <code>prepareImage</code> |
|
1024 |
* methods. |
|
1025 |
* <p> |
|
1026 |
* Information on the flags returned by this method can be found |
|
1027 |
* with the definition of the <code>ImageObserver</code> interface. |
|
1028 |
||
1029 |
* @param image the image for which to prepare a |
|
1030 |
* screen representation. |
|
1031 |
* @param width the width of the desired screen |
|
1032 |
* representation, or <code>-1</code>. |
|
1033 |
* @param height the height of the desired screen |
|
1034 |
* representation, or <code>-1</code>. |
|
1035 |
* @param observer the <code>ImageObserver</code> |
|
1036 |
* object to be notified as the |
|
1037 |
* image is being prepared. |
|
1038 |
* @return <code>true</code> if the image has already been |
|
1039 |
* fully prepared; <code>false</code> otherwise. |
|
1040 |
* @see java.awt.Component#prepareImage(java.awt.Image, |
|
1041 |
* java.awt.image.ImageObserver) |
|
1042 |
* @see java.awt.Component#prepareImage(java.awt.Image, |
|
1043 |
* int, int, java.awt.image.ImageObserver) |
|
1044 |
* @see java.awt.image.ImageObserver |
|
1045 |
*/ |
|
1046 |
public abstract boolean prepareImage(Image image, int width, int height, |
|
1047 |
ImageObserver observer); |
|
1048 |
||
1049 |
/** |
|
1050 |
* Indicates the construction status of a specified image that is |
|
1051 |
* being prepared for display. |
|
1052 |
* <p> |
|
1053 |
* If the values of the width and height arguments are both |
|
1054 |
* <code>-1</code>, this method returns the construction status of |
|
1055 |
* a screen representation of the specified image in this toolkit. |
|
1056 |
* Otherwise, this method returns the construction status of a |
|
1057 |
* scaled representation of the image at the specified width |
|
1058 |
* and height. |
|
1059 |
* <p> |
|
1060 |
* This method does not cause the image to begin loading. |
|
1061 |
* An application must call <code>prepareImage</code> to force |
|
1062 |
* the loading of an image. |
|
1063 |
* <p> |
|
1064 |
* This method is called by the component's <code>checkImage</code> |
|
1065 |
* methods. |
|
1066 |
* <p> |
|
1067 |
* Information on the flags returned by this method can be found |
|
1068 |
* with the definition of the <code>ImageObserver</code> interface. |
|
1069 |
* @param image the image whose status is being checked. |
|
1070 |
* @param width the width of the scaled version whose status is |
|
1071 |
* being checked, or <code>-1</code>. |
|
1072 |
* @param height the height of the scaled version whose status |
|
1073 |
* is being checked, or <code>-1</code>. |
|
1074 |
* @param observer the <code>ImageObserver</code> object to be |
|
1075 |
* notified as the image is being prepared. |
|
1076 |
* @return the bitwise inclusive <strong>OR</strong> of the |
|
1077 |
* <code>ImageObserver</code> flags for the |
|
1078 |
* image data that is currently available. |
|
1079 |
* @see java.awt.Toolkit#prepareImage(java.awt.Image, |
|
1080 |
* int, int, java.awt.image.ImageObserver) |
|
1081 |
* @see java.awt.Component#checkImage(java.awt.Image, |
|
1082 |
* java.awt.image.ImageObserver) |
|
1083 |
* @see java.awt.Component#checkImage(java.awt.Image, |
|
1084 |
* int, int, java.awt.image.ImageObserver) |
|
1085 |
* @see java.awt.image.ImageObserver |
|
1086 |
*/ |
|
1087 |
public abstract int checkImage(Image image, int width, int height, |
|
1088 |
ImageObserver observer); |
|
1089 |
||
1090 |
/** |
|
1091 |
* Creates an image with the specified image producer. |
|
1092 |
* @param producer the image producer to be used. |
|
1093 |
* @return an image with the specified image producer. |
|
1094 |
* @see java.awt.Image |
|
1095 |
* @see java.awt.image.ImageProducer |
|
1096 |
* @see java.awt.Component#createImage(java.awt.image.ImageProducer) |
|
1097 |
*/ |
|
1098 |
public abstract Image createImage(ImageProducer producer); |
|
1099 |
||
1100 |
/** |
|
1101 |
* Creates an image which decodes the image stored in the specified |
|
1102 |
* byte array. |
|
1103 |
* <p> |
|
1104 |
* The data must be in some image format, such as GIF or JPEG, |
|
1105 |
* that is supported by this toolkit. |
|
1106 |
* @param imagedata an array of bytes, representing |
|
1107 |
* image data in a supported image format. |
|
1108 |
* @return an image. |
|
24865
09b1d992ca72
8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents:
23717
diff
changeset
|
1109 |
* @since 1.1 |
2 | 1110 |
*/ |
1111 |
public Image createImage(byte[] imagedata) { |
|
1112 |
return createImage(imagedata, 0, imagedata.length); |
|
1113 |
} |
|
1114 |
||
1115 |
/** |
|
1116 |
* Creates an image which decodes the image stored in the specified |
|
1117 |
* byte array, and at the specified offset and length. |
|
1118 |
* The data must be in some image format, such as GIF or JPEG, |
|
1119 |
* that is supported by this toolkit. |
|
1120 |
* @param imagedata an array of bytes, representing |
|
1121 |
* image data in a supported image format. |
|
1122 |
* @param imageoffset the offset of the beginning |
|
1123 |
* of the data in the array. |
|
1124 |
* @param imagelength the length of the data in the array. |
|
1125 |
* @return an image. |
|
24865
09b1d992ca72
8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents:
23717
diff
changeset
|
1126 |
* @since 1.1 |
2 | 1127 |
*/ |
1128 |
public abstract Image createImage(byte[] imagedata, |
|
1129 |
int imageoffset, |
|
1130 |
int imagelength); |
|
1131 |
||
1132 |
/** |
|
1133 |
* Gets a <code>PrintJob</code> object which is the result of initiating |
|
1134 |
* a print operation on the toolkit's platform. |
|
1135 |
* <p> |
|
1136 |
* Each actual implementation of this method should first check if there |
|
1137 |
* is a security manager installed. If there is, the method should call |
|
1138 |
* the security manager's <code>checkPrintJobAccess</code> method to |
|
1139 |
* ensure initiation of a print operation is allowed. If the default |
|
1140 |
* implementation of <code>checkPrintJobAccess</code> is used (that is, |
|
1141 |
* that method is not overriden), then this results in a call to the |
|
1142 |
* security manager's <code>checkPermission</code> method with a <code> |
|
1143 |
* RuntimePermission("queuePrintJob")</code> permission. |
|
1144 |
* |
|
1145 |
* @param frame the parent of the print dialog. May not be null. |
|
1146 |
* @param jobtitle the title of the PrintJob. A null title is equivalent |
|
1147 |
* to "". |
|
1148 |
* @param props a Properties object containing zero or more properties. |
|
1149 |
* Properties are not standardized and are not consistent across |
|
1150 |
* implementations. Because of this, PrintJobs which require job |
|
1151 |
* and page control should use the version of this function which |
|
1152 |
* takes JobAttributes and PageAttributes objects. This object |
|
1153 |
* may be updated to reflect the user's job choices on exit. May |
|
1154 |
* be null. |
|
1155 |
* @return a <code>PrintJob</code> object, or <code>null</code> if the |
|
1156 |
* user cancelled the print job. |
|
8947
35ff89272f4f
7023011: Toolkit.getPrintJob(Frame,String,Properties) throws HE instead of specified NPE
dav
parents:
7668
diff
changeset
|
1157 |
* @throws NullPointerException if frame is null |
2 | 1158 |
* @throws SecurityException if this thread is not allowed to initiate a |
1159 |
* print job request |
|
1160 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
1161 |
* @see java.awt.PrintJob |
|
1162 |
* @see java.lang.RuntimePermission |
|
24865
09b1d992ca72
8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents:
23717
diff
changeset
|
1163 |
* @since 1.1 |
2 | 1164 |
*/ |
1165 |
public abstract PrintJob getPrintJob(Frame frame, String jobtitle, |
|
1166 |
Properties props); |
|
1167 |
||
1168 |
/** |
|
1169 |
* Gets a <code>PrintJob</code> object which is the result of initiating |
|
1170 |
* a print operation on the toolkit's platform. |
|
1171 |
* <p> |
|
1172 |
* Each actual implementation of this method should first check if there |
|
1173 |
* is a security manager installed. If there is, the method should call |
|
1174 |
* the security manager's <code>checkPrintJobAccess</code> method to |
|
1175 |
* ensure initiation of a print operation is allowed. If the default |
|
1176 |
* implementation of <code>checkPrintJobAccess</code> is used (that is, |
|
1177 |
* that method is not overriden), then this results in a call to the |
|
1178 |
* security manager's <code>checkPermission</code> method with a <code> |
|
1179 |
* RuntimePermission("queuePrintJob")</code> permission. |
|
1180 |
* |
|
9661
d837c8c8ac46
7042537: When press the 'Print' button,the NullPointerException is thrown and printdialog is not pop up.
dav
parents:
9656
diff
changeset
|
1181 |
* @param frame the parent of the print dialog. May not be null. |
2 | 1182 |
* @param jobtitle the title of the PrintJob. A null title is equivalent |
1183 |
* to "". |
|
1184 |
* @param jobAttributes a set of job attributes which will control the |
|
1185 |
* PrintJob. The attributes will be updated to reflect the user's |
|
1186 |
* choices as outlined in the JobAttributes documentation. May be |
|
1187 |
* null. |
|
1188 |
* @param pageAttributes a set of page attributes which will control the |
|
1189 |
* PrintJob. The attributes will be applied to every page in the |
|
1190 |
* job. The attributes will be updated to reflect the user's |
|
1191 |
* choices as outlined in the PageAttributes documentation. May be |
|
1192 |
* null. |
|
1193 |
* @return a <code>PrintJob</code> object, or <code>null</code> if the |
|
1194 |
* user cancelled the print job. |
|
8947
35ff89272f4f
7023011: Toolkit.getPrintJob(Frame,String,Properties) throws HE instead of specified NPE
dav
parents:
7668
diff
changeset
|
1195 |
* @throws NullPointerException if frame is null |
2 | 1196 |
* @throws IllegalArgumentException if pageAttributes specifies differing |
1197 |
* cross feed and feed resolutions. Also if this thread has |
|
1198 |
* access to the file system and jobAttributes specifies |
|
1199 |
* print to file, and the specified destination file exists but |
|
1200 |
* is a directory rather than a regular file, does not exist but |
|
1201 |
* cannot be created, or cannot be opened for any other reason. |
|
1202 |
* However in the case of print to file, if a dialog is also |
|
1203 |
* requested to be displayed then the user will be given an |
|
1204 |
* opportunity to select a file and proceed with printing. |
|
1205 |
* The dialog will ensure that the selected output file |
|
1206 |
* is valid before returning from this method. |
|
1207 |
* @throws SecurityException if this thread is not allowed to initiate a |
|
1208 |
* print job request, or if jobAttributes specifies print to file, |
|
1209 |
* and this thread is not allowed to access the file system |
|
1210 |
* @see java.awt.PrintJob |
|
1211 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
1212 |
* @see java.lang.RuntimePermission |
|
1213 |
* @see java.awt.JobAttributes |
|
1214 |
* @see java.awt.PageAttributes |
|
1215 |
* @since 1.3 |
|
1216 |
*/ |
|
1217 |
public PrintJob getPrintJob(Frame frame, String jobtitle, |
|
1218 |
JobAttributes jobAttributes, |
|
1219 |
PageAttributes pageAttributes) { |
|
1220 |
// Override to add printing support with new job/page control classes |
|
1221 |
||
1222 |
if (this != Toolkit.getDefaultToolkit()) { |
|
1223 |
return Toolkit.getDefaultToolkit().getPrintJob(frame, jobtitle, |
|
1224 |
jobAttributes, |
|
1225 |
pageAttributes); |
|
1226 |
} else { |
|
1227 |
return getPrintJob(frame, jobtitle, null); |
|
1228 |
} |
|
1229 |
} |
|
1230 |
||
1231 |
/** |
|
20123
e12d9acdc289
8003965: Toolkit.beep() documentation is ambiguous
bagiras
parents:
18275
diff
changeset
|
1232 |
* Emits an audio beep depending on native system settings and hardware |
e12d9acdc289
8003965: Toolkit.beep() documentation is ambiguous
bagiras
parents:
18275
diff
changeset
|
1233 |
* capabilities. |
24865
09b1d992ca72
8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents:
23717
diff
changeset
|
1234 |
* @since 1.1 |
2 | 1235 |
*/ |
1236 |
public abstract void beep(); |
|
1237 |
||
1238 |
/** |
|
1239 |
* Gets the singleton instance of the system Clipboard which interfaces |
|
1240 |
* with clipboard facilities provided by the native platform. This |
|
1241 |
* clipboard enables data transfer between Java programs and native |
|
1242 |
* applications which use native clipboard facilities. |
|
1243 |
* <p> |
|
25782 | 1244 |
* In addition to any and all default formats text returned by the system |
1245 |
* Clipboard's <code>getTransferData()</code> method is available in the |
|
1246 |
* following flavors: |
|
2 | 1247 |
* <ul> |
1248 |
* <li>DataFlavor.stringFlavor</li> |
|
1249 |
* <li>DataFlavor.plainTextFlavor (<b>deprecated</b>)</li> |
|
1250 |
* </ul> |
|
1251 |
* As with <code>java.awt.datatransfer.StringSelection</code>, if the |
|
1252 |
* requested flavor is <code>DataFlavor.plainTextFlavor</code>, or an |
|
1253 |
* equivalent flavor, a Reader is returned. <b>Note:</b> The behavior of |
|
1254 |
* the system Clipboard's <code>getTransferData()</code> method for <code> |
|
1255 |
* DataFlavor.plainTextFlavor</code>, and equivalent DataFlavors, is |
|
1256 |
* inconsistent with the definition of <code>DataFlavor.plainTextFlavor |
|
1257 |
* </code>. Because of this, support for <code> |
|
1258 |
* DataFlavor.plainTextFlavor</code>, and equivalent flavors, is |
|
1259 |
* <b>deprecated</b>. |
|
1260 |
* <p> |
|
1261 |
* Each actual implementation of this method should first check if there |
|
1262 |
* is a security manager installed. If there is, the method should call |
|
19807
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
18275
diff
changeset
|
1263 |
* the security manager's {@link SecurityManager#checkPermission |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
18275
diff
changeset
|
1264 |
* checkPermission} method to check {@code AWTPermission("accessClipboard")}. |
2 | 1265 |
* |
1266 |
* @return the system Clipboard |
|
1267 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
1268 |
* returns true |
|
1269 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
1270 |
* @see java.awt.datatransfer.Clipboard |
|
1271 |
* @see java.awt.datatransfer.StringSelection |
|
1272 |
* @see java.awt.datatransfer.DataFlavor#stringFlavor |
|
1273 |
* @see java.awt.datatransfer.DataFlavor#plainTextFlavor |
|
1274 |
* @see java.io.Reader |
|
1275 |
* @see java.awt.AWTPermission |
|
24865
09b1d992ca72
8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents:
23717
diff
changeset
|
1276 |
* @since 1.1 |
2 | 1277 |
*/ |
1278 |
public abstract Clipboard getSystemClipboard() |
|
1279 |
throws HeadlessException; |
|
1280 |
||
1281 |
/** |
|
1282 |
* Gets the singleton instance of the system selection as a |
|
1283 |
* <code>Clipboard</code> object. This allows an application to read and |
|
1284 |
* modify the current, system-wide selection. |
|
1285 |
* <p> |
|
1286 |
* An application is responsible for updating the system selection whenever |
|
1287 |
* the user selects text, using either the mouse or the keyboard. |
|
1288 |
* Typically, this is implemented by installing a |
|
1289 |
* <code>FocusListener</code> on all <code>Component</code>s which support |
|
1290 |
* text selection, and, between <code>FOCUS_GAINED</code> and |
|
1291 |
* <code>FOCUS_LOST</code> events delivered to that <code>Component</code>, |
|
1292 |
* updating the system selection <code>Clipboard</code> when the selection |
|
1293 |
* changes inside the <code>Component</code>. Properly updating the system |
|
1294 |
* selection ensures that a Java application will interact correctly with |
|
1295 |
* native applications and other Java applications running simultaneously |
|
1296 |
* on the system. Note that <code>java.awt.TextComponent</code> and |
|
1297 |
* <code>javax.swing.text.JTextComponent</code> already adhere to this |
|
1298 |
* policy. When using these classes, and their subclasses, developers need |
|
1299 |
* not write any additional code. |
|
1300 |
* <p> |
|
1301 |
* Some platforms do not support a system selection <code>Clipboard</code>. |
|
1302 |
* On those platforms, this method will return <code>null</code>. In such a |
|
1303 |
* case, an application is absolved from its responsibility to update the |
|
1304 |
* system selection <code>Clipboard</code> as described above. |
|
1305 |
* <p> |
|
1306 |
* Each actual implementation of this method should first check if there |
|
19807
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
18275
diff
changeset
|
1307 |
* is a security manager installed. If there is, the method should call |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
18275
diff
changeset
|
1308 |
* the security manager's {@link SecurityManager#checkPermission |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
18275
diff
changeset
|
1309 |
* checkPermission} method to check {@code AWTPermission("accessClipboard")}. |
2 | 1310 |
* |
1311 |
* @return the system selection as a <code>Clipboard</code>, or |
|
1312 |
* <code>null</code> if the native platform does not support a |
|
1313 |
* system selection <code>Clipboard</code> |
|
1314 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
1315 |
* returns true |
|
1316 |
* |
|
1317 |
* @see java.awt.datatransfer.Clipboard |
|
1318 |
* @see java.awt.event.FocusListener |
|
1319 |
* @see java.awt.event.FocusEvent#FOCUS_GAINED |
|
1320 |
* @see java.awt.event.FocusEvent#FOCUS_LOST |
|
1321 |
* @see TextComponent |
|
1322 |
* @see javax.swing.text.JTextComponent |
|
1323 |
* @see AWTPermission |
|
1324 |
* @see GraphicsEnvironment#isHeadless |
|
1325 |
* @since 1.4 |
|
1326 |
*/ |
|
1327 |
public Clipboard getSystemSelection() throws HeadlessException { |
|
9656
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1328 |
GraphicsEnvironment.checkHeadless(); |
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1329 |
|
2 | 1330 |
if (this != Toolkit.getDefaultToolkit()) { |
1331 |
return Toolkit.getDefaultToolkit().getSystemSelection(); |
|
1332 |
} else { |
|
1333 |
GraphicsEnvironment.checkHeadless(); |
|
1334 |
return null; |
|
1335 |
} |
|
1336 |
} |
|
1337 |
||
1338 |
/** |
|
1339 |
* Determines which modifier key is the appropriate accelerator |
|
1340 |
* key for menu shortcuts. |
|
1341 |
* <p> |
|
1342 |
* Menu shortcuts, which are embodied in the |
|
1343 |
* <code>MenuShortcut</code> class, are handled by the |
|
1344 |
* <code>MenuBar</code> class. |
|
1345 |
* <p> |
|
1346 |
* By default, this method returns <code>Event.CTRL_MASK</code>. |
|
1347 |
* Toolkit implementations should override this method if the |
|
1348 |
* <b>Control</b> key isn't the correct key for accelerators. |
|
1349 |
* @return the modifier mask on the <code>Event</code> class |
|
1350 |
* that is used for menu shortcuts on this toolkit. |
|
1351 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
1352 |
* returns true |
|
1353 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
1354 |
* @see java.awt.MenuBar |
|
1355 |
* @see java.awt.MenuShortcut |
|
24865
09b1d992ca72
8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents:
23717
diff
changeset
|
1356 |
* @since 1.1 |
2 | 1357 |
*/ |
1358 |
public int getMenuShortcutKeyMask() throws HeadlessException { |
|
9656
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1359 |
GraphicsEnvironment.checkHeadless(); |
9207
e0233c19a2c0
7021001: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
denis
parents:
9206
diff
changeset
|
1360 |
|
2 | 1361 |
return Event.CTRL_MASK; |
1362 |
} |
|
1363 |
||
1364 |
/** |
|
1365 |
* Returns whether the given locking key on the keyboard is currently in |
|
1366 |
* its "on" state. |
|
1367 |
* Valid key codes are |
|
1368 |
* {@link java.awt.event.KeyEvent#VK_CAPS_LOCK VK_CAPS_LOCK}, |
|
1369 |
* {@link java.awt.event.KeyEvent#VK_NUM_LOCK VK_NUM_LOCK}, |
|
1370 |
* {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and |
|
1371 |
* {@link java.awt.event.KeyEvent#VK_KANA_LOCK VK_KANA_LOCK}. |
|
1372 |
* |
|
25162 | 1373 |
* @param keyCode the key code |
1374 |
* @return {@code true} if the given key is currently in its "on" state; |
|
1375 |
* otherwise {@code false} |
|
2 | 1376 |
* @exception java.lang.IllegalArgumentException if <code>keyCode</code> |
1377 |
* is not one of the valid key codes |
|
1378 |
* @exception java.lang.UnsupportedOperationException if the host system doesn't |
|
1379 |
* allow getting the state of this key programmatically, or if the keyboard |
|
1380 |
* doesn't have this key |
|
1381 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
1382 |
* returns true |
|
1383 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
1384 |
* @since 1.3 |
|
1385 |
*/ |
|
1386 |
public boolean getLockingKeyState(int keyCode) |
|
9656
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1387 |
throws UnsupportedOperationException |
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1388 |
{ |
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1389 |
GraphicsEnvironment.checkHeadless(); |
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1390 |
|
2 | 1391 |
if (! (keyCode == KeyEvent.VK_CAPS_LOCK || keyCode == KeyEvent.VK_NUM_LOCK || |
1392 |
keyCode == KeyEvent.VK_SCROLL_LOCK || keyCode == KeyEvent.VK_KANA_LOCK)) { |
|
1393 |
throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState"); |
|
1394 |
} |
|
1395 |
throw new UnsupportedOperationException("Toolkit.getLockingKeyState"); |
|
1396 |
} |
|
1397 |
||
1398 |
/** |
|
1399 |
* Sets the state of the given locking key on the keyboard. |
|
1400 |
* Valid key codes are |
|
1401 |
* {@link java.awt.event.KeyEvent#VK_CAPS_LOCK VK_CAPS_LOCK}, |
|
1402 |
* {@link java.awt.event.KeyEvent#VK_NUM_LOCK VK_NUM_LOCK}, |
|
1403 |
* {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and |
|
1404 |
* {@link java.awt.event.KeyEvent#VK_KANA_LOCK VK_KANA_LOCK}. |
|
1405 |
* <p> |
|
1406 |
* Depending on the platform, setting the state of a locking key may |
|
1407 |
* involve event processing and therefore may not be immediately |
|
1408 |
* observable through getLockingKeyState. |
|
1409 |
* |
|
25162 | 1410 |
* @param keyCode the key code |
1411 |
* @param on the state of the key |
|
2 | 1412 |
* @exception java.lang.IllegalArgumentException if <code>keyCode</code> |
1413 |
* is not one of the valid key codes |
|
1414 |
* @exception java.lang.UnsupportedOperationException if the host system doesn't |
|
1415 |
* allow setting the state of this key programmatically, or if the keyboard |
|
1416 |
* doesn't have this key |
|
1417 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
1418 |
* returns true |
|
1419 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
1420 |
* @since 1.3 |
|
1421 |
*/ |
|
1422 |
public void setLockingKeyState(int keyCode, boolean on) |
|
9656
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1423 |
throws UnsupportedOperationException |
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1424 |
{ |
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1425 |
GraphicsEnvironment.checkHeadless(); |
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1426 |
|
2 | 1427 |
if (! (keyCode == KeyEvent.VK_CAPS_LOCK || keyCode == KeyEvent.VK_NUM_LOCK || |
1428 |
keyCode == KeyEvent.VK_SCROLL_LOCK || keyCode == KeyEvent.VK_KANA_LOCK)) { |
|
1429 |
throw new IllegalArgumentException("invalid key for Toolkit.setLockingKeyState"); |
|
1430 |
} |
|
1431 |
throw new UnsupportedOperationException("Toolkit.setLockingKeyState"); |
|
1432 |
} |
|
1433 |
||
1434 |
/** |
|
1435 |
* Give native peers the ability to query the native container |
|
1436 |
* given a native component (eg the direct parent may be lightweight). |
|
25162 | 1437 |
* |
1438 |
* @param c the component to fetch the container for |
|
1439 |
* @return the native container object for the component |
|
2 | 1440 |
*/ |
1441 |
protected static Container getNativeContainer(Component c) { |
|
1442 |
return c.getNativeContainer(); |
|
1443 |
} |
|
1444 |
||
1445 |
/** |
|
1446 |
* Creates a new custom cursor object. |
|
1447 |
* If the image to display is invalid, the cursor will be hidden (made |
|
1448 |
* completely transparent), and the hotspot will be set to (0, 0). |
|
1449 |
* |
|
1450 |
* <p>Note that multi-frame images are invalid and may cause this |
|
1451 |
* method to hang. |
|
1452 |
* |
|
21278 | 1453 |
* @param cursor the image to display when the cursor is activated |
2 | 1454 |
* @param hotSpot the X and Y of the large cursor's hot spot; the |
1455 |
* hotSpot values must be less than the Dimension returned by |
|
1456 |
* <code>getBestCursorSize</code> |
|
1457 |
* @param name a localized description of the cursor, for Java Accessibility use |
|
1458 |
* @exception IndexOutOfBoundsException if the hotSpot values are outside |
|
1459 |
* the bounds of the cursor |
|
25162 | 1460 |
* @return the cursor created |
2 | 1461 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
1462 |
* returns true |
|
1463 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
1464 |
* @since 1.2 |
|
1465 |
*/ |
|
1466 |
public Cursor createCustomCursor(Image cursor, Point hotSpot, String name) |
|
1467 |
throws IndexOutOfBoundsException, HeadlessException |
|
1468 |
{ |
|
1469 |
// Override to implement custom cursor support. |
|
1470 |
if (this != Toolkit.getDefaultToolkit()) { |
|
1471 |
return Toolkit.getDefaultToolkit(). |
|
1472 |
createCustomCursor(cursor, hotSpot, name); |
|
1473 |
} else { |
|
1474 |
return new Cursor(Cursor.DEFAULT_CURSOR); |
|
1475 |
} |
|
1476 |
} |
|
1477 |
||
1478 |
/** |
|
1479 |
* Returns the supported cursor dimension which is closest to the desired |
|
1480 |
* sizes. Systems which only support a single cursor size will return that |
|
1481 |
* size regardless of the desired sizes. Systems which don't support custom |
|
1482 |
* cursors will return a dimension of 0, 0. <p> |
|
1483 |
* Note: if an image is used whose dimensions don't match a supported size |
|
1484 |
* (as returned by this method), the Toolkit implementation will attempt to |
|
1485 |
* resize the image to a supported size. |
|
1486 |
* Since converting low-resolution images is difficult, |
|
1487 |
* no guarantees are made as to the quality of a cursor image which isn't a |
|
1488 |
* supported size. It is therefore recommended that this method |
|
1489 |
* be called and an appropriate image used so no image conversion is made. |
|
1490 |
* |
|
1491 |
* @param preferredWidth the preferred cursor width the component would like |
|
1492 |
* to use. |
|
1493 |
* @param preferredHeight the preferred cursor height the component would like |
|
1494 |
* to use. |
|
1495 |
* @return the closest matching supported cursor size, or a dimension of 0,0 if |
|
1496 |
* the Toolkit implementation doesn't support custom cursors. |
|
1497 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
1498 |
* returns true |
|
1499 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
1500 |
* @since 1.2 |
|
1501 |
*/ |
|
1502 |
public Dimension getBestCursorSize(int preferredWidth, |
|
1503 |
int preferredHeight) throws HeadlessException { |
|
9656
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1504 |
GraphicsEnvironment.checkHeadless(); |
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1505 |
|
2 | 1506 |
// Override to implement custom cursor support. |
1507 |
if (this != Toolkit.getDefaultToolkit()) { |
|
1508 |
return Toolkit.getDefaultToolkit(). |
|
1509 |
getBestCursorSize(preferredWidth, preferredHeight); |
|
1510 |
} else { |
|
1511 |
return new Dimension(0, 0); |
|
1512 |
} |
|
1513 |
} |
|
1514 |
||
1515 |
/** |
|
1516 |
* Returns the maximum number of colors the Toolkit supports in a custom cursor |
|
1517 |
* palette.<p> |
|
1518 |
* Note: if an image is used which has more colors in its palette than |
|
1519 |
* the supported maximum, the Toolkit implementation will attempt to flatten the |
|
1520 |
* palette to the maximum. Since converting low-resolution images is difficult, |
|
1521 |
* no guarantees are made as to the quality of a cursor image which has more |
|
1522 |
* colors than the system supports. It is therefore recommended that this method |
|
1523 |
* be called and an appropriate image used so no image conversion is made. |
|
1524 |
* |
|
1525 |
* @return the maximum number of colors, or zero if custom cursors are not |
|
1526 |
* supported by this Toolkit implementation. |
|
1527 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() |
|
1528 |
* returns true |
|
1529 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
1530 |
* @since 1.2 |
|
1531 |
*/ |
|
1532 |
public int getMaximumCursorColors() throws HeadlessException { |
|
9656
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1533 |
GraphicsEnvironment.checkHeadless(); |
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1534 |
|
2 | 1535 |
// Override to implement custom cursor support. |
1536 |
if (this != Toolkit.getDefaultToolkit()) { |
|
1537 |
return Toolkit.getDefaultToolkit().getMaximumCursorColors(); |
|
1538 |
} else { |
|
1539 |
return 0; |
|
1540 |
} |
|
1541 |
} |
|
1542 |
||
1543 |
/** |
|
1544 |
* Returns whether Toolkit supports this state for |
|
1545 |
* <code>Frame</code>s. This method tells whether the <em>UI |
|
1546 |
* concept</em> of, say, maximization or iconification is |
|
1547 |
* supported. It will always return false for "compound" states |
|
1548 |
* like <code>Frame.ICONIFIED|Frame.MAXIMIZED_VERT</code>. |
|
1549 |
* In other words, the rule of thumb is that only queries with a |
|
1550 |
* single frame state constant as an argument are meaningful. |
|
1551 |
* <p>Note that supporting a given concept is a platform- |
|
1552 |
* dependent feature. Due to native limitations the Toolkit |
|
1553 |
* object may report a particular state as supported, however at |
|
1554 |
* the same time the Toolkit object will be unable to apply the |
|
1555 |
* state to a given frame. This circumstance has two following |
|
1556 |
* consequences: |
|
1557 |
* <ul> |
|
1558 |
* <li>Only the return value of {@code false} for the present |
|
1559 |
* method actually indicates that the given state is not |
|
1560 |
* supported. If the method returns {@code true} the given state |
|
1561 |
* may still be unsupported and/or unavailable for a particular |
|
1562 |
* frame. |
|
1563 |
* <li>The developer should consider examining the value of the |
|
1564 |
* {@link java.awt.event.WindowEvent#getNewState} method of the |
|
1565 |
* {@code WindowEvent} received through the {@link |
|
1566 |
* java.awt.event.WindowStateListener}, rather than assuming |
|
1567 |
* that the state given to the {@code setExtendedState()} method |
|
1568 |
* will be definitely applied. For more information see the |
|
1569 |
* documentation for the {@link Frame#setExtendedState} method. |
|
1570 |
* </ul> |
|
1571 |
* |
|
1572 |
* @param state one of named frame state constants. |
|
1573 |
* @return <code>true</code> is this frame state is supported by |
|
1574 |
* this Toolkit implementation, <code>false</code> otherwise. |
|
1575 |
* @exception HeadlessException |
|
1576 |
* if <code>GraphicsEnvironment.isHeadless()</code> |
|
1577 |
* returns <code>true</code>. |
|
1578 |
* @see java.awt.Window#addWindowStateListener |
|
1579 |
* @since 1.4 |
|
1580 |
*/ |
|
1581 |
public boolean isFrameStateSupported(int state) |
|
1582 |
throws HeadlessException |
|
1583 |
{ |
|
9656
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1584 |
GraphicsEnvironment.checkHeadless(); |
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
1585 |
|
2 | 1586 |
if (this != Toolkit.getDefaultToolkit()) { |
1587 |
return Toolkit.getDefaultToolkit(). |
|
1588 |
isFrameStateSupported(state); |
|
1589 |
} else { |
|
1590 |
return (state == Frame.NORMAL); // others are not guaranteed |
|
1591 |
} |
|
1592 |
} |
|
1593 |
||
1594 |
/** |
|
1595 |
* Support for I18N: any visible strings should be stored in |
|
1596 |
* sun.awt.resources.awt.properties. The ResourceBundle is stored |
|
1597 |
* here, so that only one copy is maintained. |
|
1598 |
*/ |
|
1599 |
private static ResourceBundle resources; |
|
20147
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1600 |
private static ResourceBundle platformResources; |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1601 |
|
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1602 |
// called by platform toolkit |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1603 |
private static void setPlatformResources(ResourceBundle bundle) { |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1604 |
platformResources = bundle; |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1605 |
} |
2 | 1606 |
|
1607 |
/** |
|
1608 |
* Initialize JNI field and method ids |
|
1609 |
*/ |
|
1610 |
private static native void initIDs(); |
|
1611 |
||
1612 |
/** |
|
1613 |
* WARNING: This is a temporary workaround for a problem in the |
|
1614 |
* way the AWT loads native libraries. A number of classes in the |
|
1615 |
* AWT package have a native method, initIDs(), which initializes |
|
1616 |
* the JNI field and method ids used in the native portion of |
|
1617 |
* their implementation. |
|
1618 |
* |
|
1619 |
* Since the use and storage of these ids is done by the |
|
1620 |
* implementation libraries, the implementation of these method is |
|
1621 |
* provided by the particular AWT implementations (for example, |
|
1622 |
* "Toolkit"s/Peer), such as Motif, Microsoft Windows, or Tiny. The |
|
1623 |
* problem is that this means that the native libraries must be |
|
1624 |
* loaded by the java.* classes, which do not necessarily know the |
|
1625 |
* names of the libraries to load. A better way of doing this |
|
1626 |
* would be to provide a separate library which defines java.awt.* |
|
1627 |
* initIDs, and exports the relevant symbols out to the |
|
1628 |
* implementation libraries. |
|
1629 |
* |
|
1630 |
* For now, we know it's done by the implementation, and we assume |
|
1631 |
* that the name of the library is "awt". -br. |
|
1632 |
* |
|
1633 |
* If you change loadLibraries(), please add the change to |
|
1634 |
* java.awt.image.ColorModel.loadLibraries(). Unfortunately, |
|
1635 |
* classes can be loaded in java.awt.image that depend on |
|
1636 |
* libawt and there is no way to call Toolkit.loadLibraries() |
|
1637 |
* directly. -hung |
|
1638 |
*/ |
|
1639 |
private static boolean loaded = false; |
|
1640 |
static void loadLibraries() { |
|
1641 |
if (!loaded) { |
|
1642 |
java.security.AccessController.doPrivileged( |
|
12559
9456ceada8b1
7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents:
11270
diff
changeset
|
1643 |
new java.security.PrivilegedAction<Void>() { |
9456ceada8b1
7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents:
11270
diff
changeset
|
1644 |
public Void run() { |
9456ceada8b1
7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents:
11270
diff
changeset
|
1645 |
System.loadLibrary("awt"); |
9456ceada8b1
7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents:
11270
diff
changeset
|
1646 |
return null; |
9456ceada8b1
7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents:
11270
diff
changeset
|
1647 |
} |
9456ceada8b1
7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents:
11270
diff
changeset
|
1648 |
}); |
2 | 1649 |
loaded = true; |
1650 |
} |
|
1651 |
} |
|
1652 |
||
1653 |
static { |
|
20147
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1654 |
AWTAccessor.setToolkitAccessor( |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1655 |
new AWTAccessor.ToolkitAccessor() { |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1656 |
@Override |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1657 |
public void setPlatformResources(ResourceBundle bundle) { |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1658 |
Toolkit.setPlatformResources(bundle); |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1659 |
} |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1660 |
}); |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1661 |
|
2 | 1662 |
java.security.AccessController.doPrivileged( |
11270
d7b0b63bd082
7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents:
10068
diff
changeset
|
1663 |
new java.security.PrivilegedAction<Void>() { |
d7b0b63bd082
7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents:
10068
diff
changeset
|
1664 |
public Void run() { |
2 | 1665 |
try { |
1666 |
resources = |
|
1667 |
ResourceBundle.getBundle("sun.awt.resources.awt", |
|
1668 |
CoreResourceBundleControl.getRBControlInstance()); |
|
1669 |
} catch (MissingResourceException e) { |
|
1670 |
// No resource file; defaults will be used. |
|
1671 |
} |
|
1672 |
return null; |
|
1673 |
} |
|
1674 |
}); |
|
1675 |
||
1676 |
// ensure that the proper libraries are loaded |
|
1677 |
loadLibraries(); |
|
1678 |
initAssistiveTechnologies(); |
|
1679 |
if (!GraphicsEnvironment.isHeadless()) { |
|
1680 |
initIDs(); |
|
1681 |
} |
|
1682 |
} |
|
1683 |
||
1684 |
/** |
|
1685 |
* Gets a property with the specified key and default. |
|
1686 |
* This method returns defaultValue if the property is not found. |
|
25162 | 1687 |
* |
1688 |
* @param key the key |
|
1689 |
* @param defaultValue the default value |
|
1690 |
* @return the value of the property or the default value |
|
1691 |
* if the property was not found |
|
2 | 1692 |
*/ |
1693 |
public static String getProperty(String key, String defaultValue) { |
|
20147
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1694 |
// first try platform specific bundle |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1695 |
if (platformResources != null) { |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1696 |
try { |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1697 |
return platformResources.getString(key); |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1698 |
} |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1699 |
catch (MissingResourceException e) {} |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1700 |
} |
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1701 |
|
78e51d8fcb92
7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents:
20145
diff
changeset
|
1702 |
// then shared one |
2 | 1703 |
if (resources != null) { |
1704 |
try { |
|
1705 |
return resources.getString(key); |
|
1706 |
} |
|
1707 |
catch (MissingResourceException e) {} |
|
1708 |
} |
|
1709 |
||
1710 |
return defaultValue; |
|
1711 |
} |
|
1712 |
||
1713 |
/** |
|
1714 |
* Get the application's or applet's EventQueue instance. |
|
1715 |
* Depending on the Toolkit implementation, different EventQueues |
|
1716 |
* may be returned for different applets. Applets should |
|
1717 |
* therefore not assume that the EventQueue instance returned |
|
1718 |
* by this method will be shared by other applets or the system. |
|
1719 |
* |
|
19807
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
18275
diff
changeset
|
1720 |
* <p> If there is a security manager then its |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
18275
diff
changeset
|
1721 |
* {@link SecurityManager#checkPermission checkPermission} method |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
18275
diff
changeset
|
1722 |
* is called to check {@code AWTPermission("accessEventQueue")}. |
2 | 1723 |
* |
1724 |
* @return the <code>EventQueue</code> object |
|
1725 |
* @throws SecurityException |
|
19807
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
18275
diff
changeset
|
1726 |
* if a security manager is set and it denies access to |
9f7860fad128
8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents:
18275
diff
changeset
|
1727 |
* the {@code EventQueue} |
2 | 1728 |
* @see java.awt.AWTPermission |
1729 |
*/ |
|
1730 |
public final EventQueue getSystemEventQueue() { |
|
1731 |
SecurityManager security = System.getSecurityManager(); |
|
1732 |
if (security != null) { |
|
22060
cd4f9d7dbeda
8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents:
21957
diff
changeset
|
1733 |
security.checkPermission(AWTPermissions.CHECK_AWT_EVENTQUEUE_PERMISSION); |
2 | 1734 |
} |
1735 |
return getSystemEventQueueImpl(); |
|
1736 |
} |
|
1737 |
||
1738 |
/** |
|
1739 |
* Gets the application's or applet's <code>EventQueue</code> |
|
1740 |
* instance, without checking access. For security reasons, |
|
1741 |
* this can only be called from a <code>Toolkit</code> subclass. |
|
1742 |
* @return the <code>EventQueue</code> object |
|
1743 |
*/ |
|
1744 |
protected abstract EventQueue getSystemEventQueueImpl(); |
|
1745 |
||
1746 |
/* Accessor method for use by AWT package routines. */ |
|
1747 |
static EventQueue getEventQueue() { |
|
1748 |
return getDefaultToolkit().getSystemEventQueueImpl(); |
|
1749 |
} |
|
1750 |
||
1751 |
/** |
|
1752 |
* Creates the peer for a DragSourceContext. |
|
1753 |
* Always throws InvalidDndOperationException if |
|
1754 |
* GraphicsEnvironment.isHeadless() returns true. |
|
25162 | 1755 |
* |
1756 |
* @param dge the {@code DragGestureEvent} |
|
1757 |
* @return the peer created |
|
2 | 1758 |
* @see java.awt.GraphicsEnvironment#isHeadless |
1759 |
*/ |
|
1760 |
public abstract DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException; |
|
1761 |
||
1762 |
/** |
|
1763 |
* Creates a concrete, platform dependent, subclass of the abstract |
|
1764 |
* DragGestureRecognizer class requested, and associates it with the |
|
1765 |
* DragSource, Component and DragGestureListener specified. |
|
1766 |
* |
|
1767 |
* subclasses should override this to provide their own implementation |
|
1768 |
* |
|
1769 |
* @param abstractRecognizerClass The abstract class of the required recognizer |
|
1770 |
* @param ds The DragSource |
|
1771 |
* @param c The Component target for the DragGestureRecognizer |
|
1772 |
* @param srcActions The actions permitted for the gesture |
|
1773 |
* @param dgl The DragGestureListener |
|
1774 |
* |
|
1775 |
* @return the new object or null. Always returns null if |
|
1776 |
* GraphicsEnvironment.isHeadless() returns true. |
|
1777 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
1778 |
*/ |
|
1779 |
public <T extends DragGestureRecognizer> T |
|
1780 |
createDragGestureRecognizer(Class<T> abstractRecognizerClass, |
|
1781 |
DragSource ds, Component c, int srcActions, |
|
1782 |
DragGestureListener dgl) |
|
1783 |
{ |
|
1784 |
return null; |
|
1785 |
} |
|
1786 |
||
1787 |
/** |
|
1788 |
* Obtains a value for the specified desktop property. |
|
1789 |
* |
|
1790 |
* A desktop property is a uniquely named value for a resource that |
|
1791 |
* is Toolkit global in nature. Usually it also is an abstract |
|
1792 |
* representation for an underlying platform dependent desktop setting. |
|
1793 |
* For more information on desktop properties supported by the AWT see |
|
1794 |
* <a href="doc-files/DesktopProperties.html">AWT Desktop Properties</a>. |
|
25162 | 1795 |
* |
1796 |
* @param propertyName the property name |
|
1797 |
* @return the value for the specified desktop property |
|
2 | 1798 |
*/ |
1799 |
public final synchronized Object getDesktopProperty(String propertyName) { |
|
1800 |
// This is a workaround for headless toolkits. It would be |
|
1801 |
// better to override this method but it is declared final. |
|
1802 |
// "this instanceof" syntax defeats polymorphism. |
|
1803 |
// --mm, 03/03/00 |
|
1804 |
if (this instanceof HeadlessToolkit) { |
|
1805 |
return ((HeadlessToolkit)this).getUnderlyingToolkit() |
|
1806 |
.getDesktopProperty(propertyName); |
|
1807 |
} |
|
1808 |
||
1809 |
if (desktopProperties.isEmpty()) { |
|
1810 |
initializeDesktopProperties(); |
|
1811 |
} |
|
1812 |
||
1813 |
Object value; |
|
1814 |
||
1815 |
// This property should never be cached |
|
1816 |
if (propertyName.equals("awt.dynamicLayoutSupported")) { |
|
21275
38d2199adb1a
7172770: Default Toolkit implementation return null value for property "awt.dynamicLayoutSupported"
serb
parents:
20455
diff
changeset
|
1817 |
return getDefaultToolkit().lazilyLoadDesktopProperty(propertyName); |
2 | 1818 |
} |
1819 |
||
1820 |
value = desktopProperties.get(propertyName); |
|
1821 |
||
1822 |
if (value == null) { |
|
1823 |
value = lazilyLoadDesktopProperty(propertyName); |
|
1824 |
||
1825 |
if (value != null) { |
|
1826 |
setDesktopProperty(propertyName, value); |
|
1827 |
} |
|
1828 |
} |
|
1829 |
||
1830 |
/* for property "awt.font.desktophints" */ |
|
1831 |
if (value instanceof RenderingHints) { |
|
1832 |
value = ((RenderingHints)value).clone(); |
|
1833 |
} |
|
1834 |
||
1835 |
return value; |
|
1836 |
} |
|
1837 |
||
1838 |
/** |
|
1839 |
* Sets the named desktop property to the specified value and fires a |
|
1840 |
* property change event to notify any listeners that the value has changed. |
|
25162 | 1841 |
* |
1842 |
* @param name the property name |
|
1843 |
* @param newValue the new property value |
|
2 | 1844 |
*/ |
1845 |
protected final void setDesktopProperty(String name, Object newValue) { |
|
1846 |
// This is a workaround for headless toolkits. It would be |
|
1847 |
// better to override this method but it is declared final. |
|
1848 |
// "this instanceof" syntax defeats polymorphism. |
|
1849 |
// --mm, 03/03/00 |
|
1850 |
if (this instanceof HeadlessToolkit) { |
|
1851 |
((HeadlessToolkit)this).getUnderlyingToolkit() |
|
1852 |
.setDesktopProperty(name, newValue); |
|
1853 |
return; |
|
1854 |
} |
|
1855 |
Object oldValue; |
|
1856 |
||
1857 |
synchronized (this) { |
|
1858 |
oldValue = desktopProperties.get(name); |
|
1859 |
desktopProperties.put(name, newValue); |
|
1860 |
} |
|
1861 |
||
7009
cd2a85b8534b
6816582: WindowsFileChooserUI throws NullPointer when awt.useSystemAAFontSettings=false
rupashka
parents:
5506
diff
changeset
|
1862 |
// Don't fire change event if old and new values are null. |
cd2a85b8534b
6816582: WindowsFileChooserUI throws NullPointer when awt.useSystemAAFontSettings=false
rupashka
parents:
5506
diff
changeset
|
1863 |
// It helps to avoid recursive resending of WM_THEMECHANGED |
cd2a85b8534b
6816582: WindowsFileChooserUI throws NullPointer when awt.useSystemAAFontSettings=false
rupashka
parents:
5506
diff
changeset
|
1864 |
if (oldValue != null || newValue != null) { |
cd2a85b8534b
6816582: WindowsFileChooserUI throws NullPointer when awt.useSystemAAFontSettings=false
rupashka
parents:
5506
diff
changeset
|
1865 |
desktopPropsSupport.firePropertyChange(name, oldValue, newValue); |
cd2a85b8534b
6816582: WindowsFileChooserUI throws NullPointer when awt.useSystemAAFontSettings=false
rupashka
parents:
5506
diff
changeset
|
1866 |
} |
2 | 1867 |
} |
1868 |
||
1869 |
/** |
|
1870 |
* an opportunity to lazily evaluate desktop property values. |
|
1871 |
*/ |
|
1872 |
protected Object lazilyLoadDesktopProperty(String name) { |
|
1873 |
return null; |
|
1874 |
} |
|
1875 |
||
1876 |
/** |
|
1877 |
* initializeDesktopProperties |
|
1878 |
*/ |
|
1879 |
protected void initializeDesktopProperties() { |
|
1880 |
} |
|
1881 |
||
1882 |
/** |
|
1883 |
* Adds the specified property change listener for the named desktop |
|
9764 | 1884 |
* property. When a {@link java.beans.PropertyChangeListenerProxy} object is added, |
9475
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1885 |
* its property name is ignored, and the wrapped listener is added. |
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1886 |
* If {@code name} is {@code null} or {@code pcl} is {@code null}, |
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1887 |
* no exception is thrown and no action is performed. |
2 | 1888 |
* |
1889 |
* @param name The name of the property to listen for |
|
1890 |
* @param pcl The property change listener |
|
9475
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1891 |
* @see PropertyChangeSupport#addPropertyChangeListener(String, |
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1892 |
PropertyChangeListener) |
2 | 1893 |
* @since 1.2 |
1894 |
*/ |
|
1895 |
public void addPropertyChangeListener(String name, PropertyChangeListener pcl) { |
|
1896 |
desktopPropsSupport.addPropertyChangeListener(name, pcl); |
|
1897 |
} |
|
1898 |
||
1899 |
/** |
|
1900 |
* Removes the specified property change listener for the named |
|
9764 | 1901 |
* desktop property. When a {@link java.beans.PropertyChangeListenerProxy} object |
9475
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1902 |
* is removed, its property name is ignored, and |
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1903 |
* the wrapped listener is removed. |
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1904 |
* If {@code name} is {@code null} or {@code pcl} is {@code null}, |
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1905 |
* no exception is thrown and no action is performed. |
2 | 1906 |
* |
1907 |
* @param name The name of the property to remove |
|
1908 |
* @param pcl The property change listener |
|
9475
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1909 |
* @see PropertyChangeSupport#removePropertyChangeListener(String, |
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1910 |
PropertyChangeListener) |
2 | 1911 |
* @since 1.2 |
1912 |
*/ |
|
1913 |
public void removePropertyChangeListener(String name, PropertyChangeListener pcl) { |
|
1914 |
desktopPropsSupport.removePropertyChangeListener(name, pcl); |
|
1915 |
} |
|
1916 |
||
1917 |
/** |
|
1918 |
* Returns an array of all the property change listeners |
|
9475
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1919 |
* registered on this toolkit. The returned array |
9764 | 1920 |
* contains {@link java.beans.PropertyChangeListenerProxy} objects |
9475
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1921 |
* that associate listeners with the names of desktop properties. |
2 | 1922 |
* |
9764 | 1923 |
* @return all of this toolkit's {@link PropertyChangeListener} |
1924 |
* objects wrapped in {@code java.beans.PropertyChangeListenerProxy} objects |
|
9475
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1925 |
* or an empty array if no listeners are added |
2 | 1926 |
* |
9475
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1927 |
* @see PropertyChangeSupport#getPropertyChangeListeners() |
2 | 1928 |
* @since 1.4 |
1929 |
*/ |
|
1930 |
public PropertyChangeListener[] getPropertyChangeListeners() { |
|
1931 |
return desktopPropsSupport.getPropertyChangeListeners(); |
|
1932 |
} |
|
1933 |
||
1934 |
/** |
|
9475
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1935 |
* Returns an array of all property change listeners |
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1936 |
* associated with the specified name of a desktop property. |
2 | 1937 |
* |
1938 |
* @param propertyName the named property |
|
9475
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1939 |
* @return all of the {@code PropertyChangeListener} objects |
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1940 |
* associated with the specified name of a desktop property |
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1941 |
* or an empty array if no such listeners are added |
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1942 |
* |
abbee6a5fcef
7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents:
9210
diff
changeset
|
1943 |
* @see PropertyChangeSupport#getPropertyChangeListeners(String) |
2 | 1944 |
* @since 1.4 |
1945 |
*/ |
|
1946 |
public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { |
|
1947 |
return desktopPropsSupport.getPropertyChangeListeners(propertyName); |
|
1948 |
} |
|
1949 |
||
1950 |
protected final Map<String,Object> desktopProperties = |
|
1951 |
new HashMap<String,Object>(); |
|
1952 |
protected final PropertyChangeSupport desktopPropsSupport = |
|
1953 |
Toolkit.createPropertyChangeSupport(this); |
|
1954 |
||
1955 |
/** |
|
1956 |
* Returns whether the always-on-top mode is supported by this toolkit. |
|
1957 |
* To detect whether the always-on-top mode is supported for a |
|
1958 |
* particular Window, use {@link Window#isAlwaysOnTopSupported}. |
|
1959 |
* @return <code>true</code>, if current toolkit supports the always-on-top mode, |
|
1960 |
* otherwise returns <code>false</code> |
|
1961 |
* @see Window#isAlwaysOnTopSupported |
|
1962 |
* @see Window#setAlwaysOnTop(boolean) |
|
1963 |
* @since 1.6 |
|
1964 |
*/ |
|
1965 |
public boolean isAlwaysOnTopSupported() { |
|
1966 |
return true; |
|
1967 |
} |
|
1968 |
||
1969 |
/** |
|
1970 |
* Returns whether the given modality type is supported by this toolkit. If |
|
1971 |
* a dialog with unsupported modality type is created, then |
|
1972 |
* <code>Dialog.ModalityType.MODELESS</code> is used instead. |
|
1973 |
* |
|
1974 |
* @param modalityType modality type to be checked for support by this toolkit |
|
1975 |
* |
|
1976 |
* @return <code>true</code>, if current toolkit supports given modality |
|
1977 |
* type, <code>false</code> otherwise |
|
1978 |
* |
|
1979 |
* @see java.awt.Dialog.ModalityType |
|
1980 |
* @see java.awt.Dialog#getModalityType |
|
1981 |
* @see java.awt.Dialog#setModalityType |
|
1982 |
* |
|
1983 |
* @since 1.6 |
|
1984 |
*/ |
|
1985 |
public abstract boolean isModalityTypeSupported(Dialog.ModalityType modalityType); |
|
1986 |
||
1987 |
/** |
|
1988 |
* Returns whether the given modal exclusion type is supported by this |
|
1989 |
* toolkit. If an unsupported modal exclusion type property is set on a window, |
|
1990 |
* then <code>Dialog.ModalExclusionType.NO_EXCLUDE</code> is used instead. |
|
1991 |
* |
|
1992 |
* @param modalExclusionType modal exclusion type to be checked for support by this toolkit |
|
1993 |
* |
|
1994 |
* @return <code>true</code>, if current toolkit supports given modal exclusion |
|
1995 |
* type, <code>false</code> otherwise |
|
1996 |
* |
|
1997 |
* @see java.awt.Dialog.ModalExclusionType |
|
1998 |
* @see java.awt.Window#getModalExclusionType |
|
1999 |
* @see java.awt.Window#setModalExclusionType |
|
2000 |
* |
|
2001 |
* @since 1.6 |
|
2002 |
*/ |
|
2003 |
public abstract boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType); |
|
2004 |
||
18271
228440e64512
8014718: Netbeans IDE begins to throw a lot exceptions since 7u25 b10
leonidr
parents:
15318
diff
changeset
|
2005 |
// 8014718: logging has been removed from SunToolkit |
2 | 2006 |
|
2007 |
private static final int LONG_BITS = 64; |
|
2008 |
private int[] calls = new int[LONG_BITS]; |
|
2009 |
private static volatile long enabledOnToolkitMask; |
|
2010 |
private AWTEventListener eventListener = null; |
|
11270
d7b0b63bd082
7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents:
10068
diff
changeset
|
2011 |
private WeakHashMap<AWTEventListener, SelectiveAWTEventListener> listener2SelectiveListener = new WeakHashMap<>(); |
2 | 2012 |
|
2013 |
/* |
|
2014 |
* Extracts a "pure" AWTEventListener from a AWTEventListenerProxy, |
|
2015 |
* if the listener is proxied. |
|
2016 |
*/ |
|
2017 |
static private AWTEventListener deProxyAWTEventListener(AWTEventListener l) |
|
2018 |
{ |
|
2019 |
AWTEventListener localL = l; |
|
2020 |
||
2021 |
if (localL == null) { |
|
2022 |
return null; |
|
2023 |
} |
|
2024 |
// if user passed in a AWTEventListenerProxy object, extract |
|
2025 |
// the listener |
|
2026 |
if (l instanceof AWTEventListenerProxy) { |
|
2027 |
localL = ((AWTEventListenerProxy)l).getListener(); |
|
2028 |
} |
|
2029 |
return localL; |
|
2030 |
} |
|
2031 |
||
2032 |
/** |
|
2033 |
* Adds an AWTEventListener to receive all AWTEvents dispatched |
|
2034 |
* system-wide that conform to the given <code>eventMask</code>. |
|
2035 |
* <p> |
|
2036 |
* First, if there is a security manager, its <code>checkPermission</code> |
|
2037 |
* method is called with an |
|
2038 |
* <code>AWTPermission("listenToAllAWTEvents")</code> permission. |
|
2039 |
* This may result in a SecurityException. |
|
2040 |
* <p> |
|
2041 |
* <code>eventMask</code> is a bitmask of event types to receive. |
|
2042 |
* It is constructed by bitwise OR-ing together the event masks |
|
2043 |
* defined in <code>AWTEvent</code>. |
|
2044 |
* <p> |
|
2045 |
* Note: event listener use is not recommended for normal |
|
2046 |
* application use, but are intended solely to support special |
|
2047 |
* purpose facilities including support for accessibility, |
|
2048 |
* event record/playback, and diagnostic tracing. |
|
2049 |
* |
|
2050 |
* If listener is null, no exception is thrown and no action is performed. |
|
2051 |
* |
|
2052 |
* @param listener the event listener. |
|
2053 |
* @param eventMask the bitmask of event types to receive |
|
2054 |
* @throws SecurityException |
|
2055 |
* if a security manager exists and its |
|
2056 |
* <code>checkPermission</code> method doesn't allow the operation. |
|
2057 |
* @see #removeAWTEventListener |
|
2058 |
* @see #getAWTEventListeners |
|
2059 |
* @see SecurityManager#checkPermission |
|
2060 |
* @see java.awt.AWTEvent |
|
2061 |
* @see java.awt.AWTPermission |
|
2062 |
* @see java.awt.event.AWTEventListener |
|
2063 |
* @see java.awt.event.AWTEventListenerProxy |
|
2064 |
* @since 1.2 |
|
2065 |
*/ |
|
2066 |
public void addAWTEventListener(AWTEventListener listener, long eventMask) { |
|
2067 |
AWTEventListener localL = deProxyAWTEventListener(listener); |
|
2068 |
||
2069 |
if (localL == null) { |
|
2070 |
return; |
|
2071 |
} |
|
2072 |
SecurityManager security = System.getSecurityManager(); |
|
2073 |
if (security != null) { |
|
22060
cd4f9d7dbeda
8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents:
21957
diff
changeset
|
2074 |
security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION); |
2 | 2075 |
} |
2076 |
synchronized (this) { |
|
2077 |
SelectiveAWTEventListener selectiveListener = |
|
11270
d7b0b63bd082
7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents:
10068
diff
changeset
|
2078 |
listener2SelectiveListener.get(localL); |
2 | 2079 |
|
2080 |
if (selectiveListener == null) { |
|
2081 |
// Create a new selectiveListener. |
|
2082 |
selectiveListener = new SelectiveAWTEventListener(localL, |
|
2083 |
eventMask); |
|
2084 |
listener2SelectiveListener.put(localL, selectiveListener); |
|
2085 |
eventListener = ToolkitEventMulticaster.add(eventListener, |
|
2086 |
selectiveListener); |
|
2087 |
} |
|
2088 |
// OR the eventMask into the selectiveListener's event mask. |
|
2089 |
selectiveListener.orEventMasks(eventMask); |
|
2090 |
||
2091 |
enabledOnToolkitMask |= eventMask; |
|
2092 |
||
2093 |
long mask = eventMask; |
|
2094 |
for (int i=0; i<LONG_BITS; i++) { |
|
2095 |
// If no bits are set, break out of loop. |
|
2096 |
if (mask == 0) { |
|
2097 |
break; |
|
2098 |
} |
|
2099 |
if ((mask & 1L) != 0) { // Always test bit 0. |
|
2100 |
calls[i]++; |
|
2101 |
} |
|
2102 |
mask >>>= 1; // Right shift, fill with zeros on left. |
|
2103 |
} |
|
2104 |
} |
|
2105 |
} |
|
2106 |
||
2107 |
/** |
|
2108 |
* Removes an AWTEventListener from receiving dispatched AWTEvents. |
|
2109 |
* <p> |
|
2110 |
* First, if there is a security manager, its <code>checkPermission</code> |
|
2111 |
* method is called with an |
|
2112 |
* <code>AWTPermission("listenToAllAWTEvents")</code> permission. |
|
2113 |
* This may result in a SecurityException. |
|
2114 |
* <p> |
|
2115 |
* Note: event listener use is not recommended for normal |
|
2116 |
* application use, but are intended solely to support special |
|
2117 |
* purpose facilities including support for accessibility, |
|
2118 |
* event record/playback, and diagnostic tracing. |
|
2119 |
* |
|
2120 |
* If listener is null, no exception is thrown and no action is performed. |
|
2121 |
* |
|
2122 |
* @param listener the event listener. |
|
2123 |
* @throws SecurityException |
|
2124 |
* if a security manager exists and its |
|
2125 |
* <code>checkPermission</code> method doesn't allow the operation. |
|
2126 |
* @see #addAWTEventListener |
|
2127 |
* @see #getAWTEventListeners |
|
2128 |
* @see SecurityManager#checkPermission |
|
2129 |
* @see java.awt.AWTEvent |
|
2130 |
* @see java.awt.AWTPermission |
|
2131 |
* @see java.awt.event.AWTEventListener |
|
2132 |
* @see java.awt.event.AWTEventListenerProxy |
|
2133 |
* @since 1.2 |
|
2134 |
*/ |
|
2135 |
public void removeAWTEventListener(AWTEventListener listener) { |
|
2136 |
AWTEventListener localL = deProxyAWTEventListener(listener); |
|
2137 |
||
2138 |
if (listener == null) { |
|
2139 |
return; |
|
2140 |
} |
|
2141 |
SecurityManager security = System.getSecurityManager(); |
|
2142 |
if (security != null) { |
|
22060
cd4f9d7dbeda
8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents:
21957
diff
changeset
|
2143 |
security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION); |
2 | 2144 |
} |
2145 |
||
2146 |
synchronized (this) { |
|
2147 |
SelectiveAWTEventListener selectiveListener = |
|
11270
d7b0b63bd082
7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents:
10068
diff
changeset
|
2148 |
listener2SelectiveListener.get(localL); |
2 | 2149 |
|
2150 |
if (selectiveListener != null) { |
|
2151 |
listener2SelectiveListener.remove(localL); |
|
2152 |
int[] listenerCalls = selectiveListener.getCalls(); |
|
2153 |
for (int i=0; i<LONG_BITS; i++) { |
|
2154 |
calls[i] -= listenerCalls[i]; |
|
2155 |
assert calls[i] >= 0: "Negative Listeners count"; |
|
2156 |
||
2157 |
if (calls[i] == 0) { |
|
2158 |
enabledOnToolkitMask &= ~(1L<<i); |
|
2159 |
} |
|
2160 |
} |
|
2161 |
} |
|
2162 |
eventListener = ToolkitEventMulticaster.remove(eventListener, |
|
2163 |
(selectiveListener == null) ? localL : selectiveListener); |
|
2164 |
} |
|
2165 |
} |
|
2166 |
||
2167 |
static boolean enabledOnToolkit(long eventMask) { |
|
2168 |
return (enabledOnToolkitMask & eventMask) != 0; |
|
2169 |
} |
|
2170 |
||
2171 |
synchronized int countAWTEventListeners(long eventMask) { |
|
2172 |
int ci = 0; |
|
2173 |
for (; eventMask != 0; eventMask >>>= 1, ci++) { |
|
2174 |
} |
|
2175 |
ci--; |
|
2176 |
return calls[ci]; |
|
2177 |
} |
|
2178 |
/** |
|
2179 |
* Returns an array of all the <code>AWTEventListener</code>s |
|
2180 |
* registered on this toolkit. |
|
2181 |
* If there is a security manager, its {@code checkPermission} |
|
2182 |
* method is called with an |
|
2183 |
* {@code AWTPermission("listenToAllAWTEvents")} permission. |
|
2184 |
* This may result in a SecurityException. |
|
2185 |
* Listeners can be returned |
|
2186 |
* within <code>AWTEventListenerProxy</code> objects, which also contain |
|
2187 |
* the event mask for the given listener. |
|
2188 |
* Note that listener objects |
|
2189 |
* added multiple times appear only once in the returned array. |
|
2190 |
* |
|
2191 |
* @return all of the <code>AWTEventListener</code>s or an empty |
|
2192 |
* array if no listeners are currently registered |
|
2193 |
* @throws SecurityException |
|
2194 |
* if a security manager exists and its |
|
2195 |
* <code>checkPermission</code> method doesn't allow the operation. |
|
2196 |
* @see #addAWTEventListener |
|
2197 |
* @see #removeAWTEventListener |
|
2198 |
* @see SecurityManager#checkPermission |
|
2199 |
* @see java.awt.AWTEvent |
|
2200 |
* @see java.awt.AWTPermission |
|
2201 |
* @see java.awt.event.AWTEventListener |
|
2202 |
* @see java.awt.event.AWTEventListenerProxy |
|
2203 |
* @since 1.4 |
|
2204 |
*/ |
|
2205 |
public AWTEventListener[] getAWTEventListeners() { |
|
2206 |
SecurityManager security = System.getSecurityManager(); |
|
2207 |
if (security != null) { |
|
22060
cd4f9d7dbeda
8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents:
21957
diff
changeset
|
2208 |
security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION); |
2 | 2209 |
} |
2210 |
synchronized (this) { |
|
2211 |
EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class); |
|
2212 |
||
2213 |
AWTEventListener[] ret = new AWTEventListener[la.length]; |
|
2214 |
for (int i = 0; i < la.length; i++) { |
|
2215 |
SelectiveAWTEventListener sael = (SelectiveAWTEventListener)la[i]; |
|
2216 |
AWTEventListener tempL = sael.getListener(); |
|
2217 |
//assert tempL is not an AWTEventListenerProxy - we should |
|
2218 |
// have weeded them all out |
|
2219 |
// don't want to wrap a proxy inside a proxy |
|
2220 |
ret[i] = new AWTEventListenerProxy(sael.getEventMask(), tempL); |
|
2221 |
} |
|
2222 |
return ret; |
|
2223 |
} |
|
2224 |
} |
|
2225 |
||
2226 |
/** |
|
2227 |
* Returns an array of all the <code>AWTEventListener</code>s |
|
2228 |
* registered on this toolkit which listen to all of the event |
|
2229 |
* types specified in the {@code eventMask} argument. |
|
2230 |
* If there is a security manager, its {@code checkPermission} |
|
2231 |
* method is called with an |
|
2232 |
* {@code AWTPermission("listenToAllAWTEvents")} permission. |
|
2233 |
* This may result in a SecurityException. |
|
2234 |
* Listeners can be returned |
|
2235 |
* within <code>AWTEventListenerProxy</code> objects, which also contain |
|
2236 |
* the event mask for the given listener. |
|
2237 |
* Note that listener objects |
|
2238 |
* added multiple times appear only once in the returned array. |
|
2239 |
* |
|
2240 |
* @param eventMask the bitmask of event types to listen for |
|
2241 |
* @return all of the <code>AWTEventListener</code>s registered |
|
2242 |
* on this toolkit for the specified |
|
2243 |
* event types, or an empty array if no such listeners |
|
2244 |
* are currently registered |
|
2245 |
* @throws SecurityException |
|
2246 |
* if a security manager exists and its |
|
2247 |
* <code>checkPermission</code> method doesn't allow the operation. |
|
2248 |
* @see #addAWTEventListener |
|
2249 |
* @see #removeAWTEventListener |
|
2250 |
* @see SecurityManager#checkPermission |
|
2251 |
* @see java.awt.AWTEvent |
|
2252 |
* @see java.awt.AWTPermission |
|
2253 |
* @see java.awt.event.AWTEventListener |
|
2254 |
* @see java.awt.event.AWTEventListenerProxy |
|
2255 |
* @since 1.4 |
|
2256 |
*/ |
|
2257 |
public AWTEventListener[] getAWTEventListeners(long eventMask) { |
|
2258 |
SecurityManager security = System.getSecurityManager(); |
|
2259 |
if (security != null) { |
|
22060
cd4f9d7dbeda
8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents:
21957
diff
changeset
|
2260 |
security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION); |
2 | 2261 |
} |
2262 |
synchronized (this) { |
|
2263 |
EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class); |
|
2264 |
||
11270
d7b0b63bd082
7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents:
10068
diff
changeset
|
2265 |
java.util.List<AWTEventListenerProxy> list = new ArrayList<>(la.length); |
2 | 2266 |
|
2267 |
for (int i = 0; i < la.length; i++) { |
|
2268 |
SelectiveAWTEventListener sael = (SelectiveAWTEventListener)la[i]; |
|
2269 |
if ((sael.getEventMask() & eventMask) == eventMask) { |
|
2270 |
//AWTEventListener tempL = sael.getListener(); |
|
2271 |
list.add(new AWTEventListenerProxy(sael.getEventMask(), |
|
2272 |
sael.getListener())); |
|
2273 |
} |
|
2274 |
} |
|
11270
d7b0b63bd082
7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents:
10068
diff
changeset
|
2275 |
return list.toArray(new AWTEventListener[0]); |
2 | 2276 |
} |
2277 |
} |
|
2278 |
||
2279 |
/* |
|
2280 |
* This method notifies any AWTEventListeners that an event |
|
2281 |
* is about to be dispatched. |
|
2282 |
* |
|
2283 |
* @param theEvent the event which will be dispatched. |
|
2284 |
*/ |
|
2285 |
void notifyAWTEventListeners(AWTEvent theEvent) { |
|
2286 |
// This is a workaround for headless toolkits. It would be |
|
2287 |
// better to override this method but it is declared package private. |
|
2288 |
// "this instanceof" syntax defeats polymorphism. |
|
2289 |
// --mm, 03/03/00 |
|
2290 |
if (this instanceof HeadlessToolkit) { |
|
2291 |
((HeadlessToolkit)this).getUnderlyingToolkit() |
|
2292 |
.notifyAWTEventListeners(theEvent); |
|
2293 |
return; |
|
2294 |
} |
|
2295 |
||
2296 |
AWTEventListener eventListener = this.eventListener; |
|
2297 |
if (eventListener != null) { |
|
2298 |
eventListener.eventDispatched(theEvent); |
|
2299 |
} |
|
2300 |
} |
|
2301 |
||
2302 |
static private class ToolkitEventMulticaster extends AWTEventMulticaster |
|
2303 |
implements AWTEventListener { |
|
2304 |
// Implementation cloned from AWTEventMulticaster. |
|
2305 |
||
2306 |
ToolkitEventMulticaster(AWTEventListener a, AWTEventListener b) { |
|
2307 |
super(a, b); |
|
2308 |
} |
|
2309 |
||
22282
cf7ce8b79a25
8031550: Fix overloads lint warnings in client code
darcy
parents:
22060
diff
changeset
|
2310 |
@SuppressWarnings("overloads") |
2 | 2311 |
static AWTEventListener add(AWTEventListener a, |
2312 |
AWTEventListener b) { |
|
2313 |
if (a == null) return b; |
|
2314 |
if (b == null) return a; |
|
2315 |
return new ToolkitEventMulticaster(a, b); |
|
2316 |
} |
|
2317 |
||
22282
cf7ce8b79a25
8031550: Fix overloads lint warnings in client code
darcy
parents:
22060
diff
changeset
|
2318 |
@SuppressWarnings("overloads") |
2 | 2319 |
static AWTEventListener remove(AWTEventListener l, |
2320 |
AWTEventListener oldl) { |
|
2321 |
return (AWTEventListener) removeInternal(l, oldl); |
|
2322 |
} |
|
2323 |
||
2324 |
// #4178589: must overload remove(EventListener) to call our add() |
|
2325 |
// instead of the static addInternal() so we allocate a |
|
2326 |
// ToolkitEventMulticaster instead of an AWTEventMulticaster. |
|
2327 |
// Note: this method is called by AWTEventListener.removeInternal(), |
|
2328 |
// so its method signature must match AWTEventListener.remove(). |
|
2329 |
protected EventListener remove(EventListener oldl) { |
|
2330 |
if (oldl == a) return b; |
|
2331 |
if (oldl == b) return a; |
|
2332 |
AWTEventListener a2 = (AWTEventListener)removeInternal(a, oldl); |
|
2333 |
AWTEventListener b2 = (AWTEventListener)removeInternal(b, oldl); |
|
2334 |
if (a2 == a && b2 == b) { |
|
2335 |
return this; // it's not here |
|
2336 |
} |
|
2337 |
return add(a2, b2); |
|
2338 |
} |
|
2339 |
||
2340 |
public void eventDispatched(AWTEvent event) { |
|
2341 |
((AWTEventListener)a).eventDispatched(event); |
|
2342 |
((AWTEventListener)b).eventDispatched(event); |
|
2343 |
} |
|
2344 |
} |
|
2345 |
||
2346 |
private class SelectiveAWTEventListener implements AWTEventListener { |
|
2347 |
AWTEventListener listener; |
|
2348 |
private long eventMask; |
|
2349 |
// This array contains the number of times to call the eventlistener |
|
2350 |
// for each event type. |
|
2351 |
int[] calls = new int[Toolkit.LONG_BITS]; |
|
2352 |
||
2353 |
public AWTEventListener getListener() {return listener;} |
|
2354 |
public long getEventMask() {return eventMask;} |
|
2355 |
public int[] getCalls() {return calls;} |
|
2356 |
||
2357 |
public void orEventMasks(long mask) { |
|
2358 |
eventMask |= mask; |
|
2359 |
// For each event bit set in mask, increment its call count. |
|
2360 |
for (int i=0; i<Toolkit.LONG_BITS; i++) { |
|
2361 |
// If no bits are set, break out of loop. |
|
2362 |
if (mask == 0) { |
|
2363 |
break; |
|
2364 |
} |
|
2365 |
if ((mask & 1L) != 0) { // Always test bit 0. |
|
2366 |
calls[i]++; |
|
2367 |
} |
|
2368 |
mask >>>= 1; // Right shift, fill with zeros on left. |
|
2369 |
} |
|
2370 |
} |
|
2371 |
||
2372 |
SelectiveAWTEventListener(AWTEventListener l, long mask) { |
|
2373 |
listener = l; |
|
2374 |
eventMask = mask; |
|
2375 |
} |
|
2376 |
||
2377 |
public void eventDispatched(AWTEvent event) { |
|
2378 |
long eventBit = 0; // Used to save the bit of the event type. |
|
2379 |
if (((eventBit = eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 && |
|
2380 |
event.id >= ComponentEvent.COMPONENT_FIRST && |
|
2381 |
event.id <= ComponentEvent.COMPONENT_LAST) |
|
2382 |
|| ((eventBit = eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 && |
|
2383 |
event.id >= ContainerEvent.CONTAINER_FIRST && |
|
2384 |
event.id <= ContainerEvent.CONTAINER_LAST) |
|
2385 |
|| ((eventBit = eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0 && |
|
2386 |
event.id >= FocusEvent.FOCUS_FIRST && |
|
2387 |
event.id <= FocusEvent.FOCUS_LAST) |
|
2388 |
|| ((eventBit = eventMask & AWTEvent.KEY_EVENT_MASK) != 0 && |
|
2389 |
event.id >= KeyEvent.KEY_FIRST && |
|
2390 |
event.id <= KeyEvent.KEY_LAST) |
|
2391 |
|| ((eventBit = eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0 && |
|
2392 |
event.id == MouseEvent.MOUSE_WHEEL) |
|
2393 |
|| ((eventBit = eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0 && |
|
2394 |
(event.id == MouseEvent.MOUSE_MOVED || |
|
2395 |
event.id == MouseEvent.MOUSE_DRAGGED)) |
|
2396 |
|| ((eventBit = eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0 && |
|
2397 |
event.id != MouseEvent.MOUSE_MOVED && |
|
2398 |
event.id != MouseEvent.MOUSE_DRAGGED && |
|
2399 |
event.id != MouseEvent.MOUSE_WHEEL && |
|
2400 |
event.id >= MouseEvent.MOUSE_FIRST && |
|
2401 |
event.id <= MouseEvent.MOUSE_LAST) |
|
2402 |
|| ((eventBit = eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0 && |
|
2403 |
(event.id >= WindowEvent.WINDOW_FIRST && |
|
2404 |
event.id <= WindowEvent.WINDOW_LAST)) |
|
2405 |
|| ((eventBit = eventMask & AWTEvent.ACTION_EVENT_MASK) != 0 && |
|
2406 |
event.id >= ActionEvent.ACTION_FIRST && |
|
2407 |
event.id <= ActionEvent.ACTION_LAST) |
|
2408 |
|| ((eventBit = eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0 && |
|
2409 |
event.id >= AdjustmentEvent.ADJUSTMENT_FIRST && |
|
2410 |
event.id <= AdjustmentEvent.ADJUSTMENT_LAST) |
|
2411 |
|| ((eventBit = eventMask & AWTEvent.ITEM_EVENT_MASK) != 0 && |
|
2412 |
event.id >= ItemEvent.ITEM_FIRST && |
|
2413 |
event.id <= ItemEvent.ITEM_LAST) |
|
2414 |
|| ((eventBit = eventMask & AWTEvent.TEXT_EVENT_MASK) != 0 && |
|
2415 |
event.id >= TextEvent.TEXT_FIRST && |
|
2416 |
event.id <= TextEvent.TEXT_LAST) |
|
2417 |
|| ((eventBit = eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0 && |
|
2418 |
event.id >= InputMethodEvent.INPUT_METHOD_FIRST && |
|
2419 |
event.id <= InputMethodEvent.INPUT_METHOD_LAST) |
|
2420 |
|| ((eventBit = eventMask & AWTEvent.PAINT_EVENT_MASK) != 0 && |
|
2421 |
event.id >= PaintEvent.PAINT_FIRST && |
|
2422 |
event.id <= PaintEvent.PAINT_LAST) |
|
2423 |
|| ((eventBit = eventMask & AWTEvent.INVOCATION_EVENT_MASK) != 0 && |
|
2424 |
event.id >= InvocationEvent.INVOCATION_FIRST && |
|
2425 |
event.id <= InvocationEvent.INVOCATION_LAST) |
|
2426 |
|| ((eventBit = eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0 && |
|
2427 |
event.id == HierarchyEvent.HIERARCHY_CHANGED) |
|
2428 |
|| ((eventBit = eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0 && |
|
2429 |
(event.id == HierarchyEvent.ANCESTOR_MOVED || |
|
2430 |
event.id == HierarchyEvent.ANCESTOR_RESIZED)) |
|
2431 |
|| ((eventBit = eventMask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0 && |
|
2432 |
event.id == WindowEvent.WINDOW_STATE_CHANGED) |
|
2433 |
|| ((eventBit = eventMask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0 && |
|
2434 |
(event.id == WindowEvent.WINDOW_GAINED_FOCUS || |
|
2435 |
event.id == WindowEvent.WINDOW_LOST_FOCUS)) |
|
2436 |
|| ((eventBit = eventMask & sun.awt.SunToolkit.GRAB_EVENT_MASK) != 0 && |
|
2437 |
(event instanceof sun.awt.UngrabEvent))) { |
|
2438 |
// Get the index of the call count for this event type. |
|
2439 |
// Instead of using Math.log(...) we will calculate it with |
|
2440 |
// bit shifts. That's what previous implementation looked like: |
|
2441 |
// |
|
2442 |
// int ci = (int) (Math.log(eventBit)/Math.log(2)); |
|
2443 |
int ci = 0; |
|
2444 |
for (long eMask = eventBit; eMask != 0; eMask >>>= 1, ci++) { |
|
2445 |
} |
|
2446 |
ci--; |
|
2447 |
// Call the listener as many times as it was added for this |
|
2448 |
// event type. |
|
2449 |
for (int i=0; i<calls[ci]; i++) { |
|
2450 |
listener.eventDispatched(event); |
|
2451 |
} |
|
2452 |
} |
|
2453 |
} |
|
2454 |
} |
|
2455 |
||
2456 |
/** |
|
2457 |
* Returns a map of visual attributes for the abstract level description |
|
2458 |
* of the given input method highlight, or null if no mapping is found. |
|
2459 |
* The style field of the input method highlight is ignored. The map |
|
2460 |
* returned is unmodifiable. |
|
2461 |
* @param highlight input method highlight |
|
2462 |
* @return style attribute map, or <code>null</code> |
|
2463 |
* @exception HeadlessException if |
|
2464 |
* <code>GraphicsEnvironment.isHeadless</code> returns true |
|
2465 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
2466 |
* @since 1.3 |
|
2467 |
*/ |
|
2468 |
public abstract Map<java.awt.font.TextAttribute,?> |
|
2469 |
mapInputMethodHighlight(InputMethodHighlight highlight) |
|
2470 |
throws HeadlessException; |
|
2471 |
||
2472 |
private static PropertyChangeSupport createPropertyChangeSupport(Toolkit toolkit) { |
|
2473 |
if (toolkit instanceof SunToolkit || toolkit instanceof HeadlessToolkit) { |
|
2474 |
return new DesktopPropertyChangeSupport(toolkit); |
|
2475 |
} else { |
|
2476 |
return new PropertyChangeSupport(toolkit); |
|
2477 |
} |
|
2478 |
} |
|
2479 |
||
11270
d7b0b63bd082
7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents:
10068
diff
changeset
|
2480 |
@SuppressWarnings("serial") |
2 | 2481 |
private static class DesktopPropertyChangeSupport extends PropertyChangeSupport { |
11270
d7b0b63bd082
7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents:
10068
diff
changeset
|
2482 |
|
2 | 2483 |
private static final StringBuilder PROP_CHANGE_SUPPORT_KEY = |
2484 |
new StringBuilder("desktop property change support key"); |
|
2485 |
private final Object source; |
|
2486 |
||
2487 |
public DesktopPropertyChangeSupport(Object sourceBean) { |
|
2488 |
super(sourceBean); |
|
2489 |
source = sourceBean; |
|
2490 |
} |
|
2491 |
||
2492 |
@Override |
|
2493 |
public synchronized void addPropertyChangeListener( |
|
2494 |
String propertyName, |
|
2495 |
PropertyChangeListener listener) |
|
2496 |
{ |
|
2497 |
PropertyChangeSupport pcs = (PropertyChangeSupport) |
|
2498 |
AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); |
|
2499 |
if (null == pcs) { |
|
2500 |
pcs = new PropertyChangeSupport(source); |
|
2501 |
AppContext.getAppContext().put(PROP_CHANGE_SUPPORT_KEY, pcs); |
|
2502 |
} |
|
2503 |
pcs.addPropertyChangeListener(propertyName, listener); |
|
2504 |
} |
|
2505 |
||
2506 |
@Override |
|
2507 |
public synchronized void removePropertyChangeListener( |
|
2508 |
String propertyName, |
|
2509 |
PropertyChangeListener listener) |
|
2510 |
{ |
|
2511 |
PropertyChangeSupport pcs = (PropertyChangeSupport) |
|
2512 |
AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); |
|
2513 |
if (null != pcs) { |
|
2514 |
pcs.removePropertyChangeListener(propertyName, listener); |
|
2515 |
} |
|
2516 |
} |
|
2517 |
||
2518 |
@Override |
|
2519 |
public synchronized PropertyChangeListener[] getPropertyChangeListeners() |
|
2520 |
{ |
|
2521 |
PropertyChangeSupport pcs = (PropertyChangeSupport) |
|
2522 |
AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); |
|
2523 |
if (null != pcs) { |
|
2524 |
return pcs.getPropertyChangeListeners(); |
|
2525 |
} else { |
|
2526 |
return new PropertyChangeListener[0]; |
|
2527 |
} |
|
2528 |
} |
|
2529 |
||
2530 |
@Override |
|
2531 |
public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) |
|
2532 |
{ |
|
2533 |
PropertyChangeSupport pcs = (PropertyChangeSupport) |
|
2534 |
AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); |
|
2535 |
if (null != pcs) { |
|
2536 |
return pcs.getPropertyChangeListeners(propertyName); |
|
2537 |
} else { |
|
2538 |
return new PropertyChangeListener[0]; |
|
2539 |
} |
|
2540 |
} |
|
2541 |
||
2542 |
@Override |
|
2543 |
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) { |
|
2544 |
PropertyChangeSupport pcs = (PropertyChangeSupport) |
|
2545 |
AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); |
|
2546 |
if (null == pcs) { |
|
2547 |
pcs = new PropertyChangeSupport(source); |
|
2548 |
AppContext.getAppContext().put(PROP_CHANGE_SUPPORT_KEY, pcs); |
|
2549 |
} |
|
2550 |
pcs.addPropertyChangeListener(listener); |
|
2551 |
} |
|
2552 |
||
2553 |
@Override |
|
2554 |
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) { |
|
2555 |
PropertyChangeSupport pcs = (PropertyChangeSupport) |
|
2556 |
AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); |
|
2557 |
if (null != pcs) { |
|
2558 |
pcs.removePropertyChangeListener(listener); |
|
2559 |
} |
|
2560 |
} |
|
2561 |
||
2562 |
/* |
|
2563 |
* we do expect that all other fireXXX() methods of java.beans.PropertyChangeSupport |
|
2564 |
* use this method. If this will be changed we will need to change this class. |
|
2565 |
*/ |
|
2566 |
@Override |
|
2567 |
public void firePropertyChange(final PropertyChangeEvent evt) { |
|
2568 |
Object oldValue = evt.getOldValue(); |
|
2569 |
Object newValue = evt.getNewValue(); |
|
25544 | 2570 |
String propertyName = evt.getPropertyName(); |
2 | 2571 |
if (oldValue != null && newValue != null && oldValue.equals(newValue)) { |
2572 |
return; |
|
2573 |
} |
|
25544 | 2574 |
Runnable updater = new Runnable() { |
2575 |
public void run() { |
|
2576 |
PropertyChangeSupport pcs = (PropertyChangeSupport) |
|
2577 |
AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); |
|
2578 |
if (null != pcs) { |
|
2579 |
pcs.firePropertyChange(evt); |
|
2580 |
} |
|
2581 |
} |
|
2582 |
}; |
|
2583 |
final AppContext currentAppContext = AppContext.getAppContext(); |
|
2 | 2584 |
for (AppContext appContext : AppContext.getAppContexts()) { |
2585 |
if (null == appContext || appContext.isDisposed()) { |
|
2586 |
continue; |
|
2587 |
} |
|
25544 | 2588 |
if (currentAppContext == appContext) { |
2589 |
updater.run(); |
|
2590 |
} else { |
|
2591 |
final PeerEvent e = new PeerEvent(source, updater, PeerEvent.ULTIMATE_PRIORITY_EVENT); |
|
2592 |
SunToolkit.postEvent(appContext, e); |
|
2593 |
} |
|
2 | 2594 |
} |
2595 |
} |
|
2596 |
} |
|
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2597 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2598 |
/** |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2599 |
* Reports whether events from extra mouse buttons are allowed to be processed and posted into |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2600 |
* {@code EventQueue}. |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2601 |
* <br> |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2602 |
* To change the returned value it is necessary to set the {@code sun.awt.enableExtraMouseButtons} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2603 |
* property before the {@code Toolkit} class initialization. This setting could be done on the application |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2604 |
* startup by the following command: |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2605 |
* <pre> |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2606 |
* java -Dsun.awt.enableExtraMouseButtons=false Application |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2607 |
* </pre> |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2608 |
* Alternatively, the property could be set in the application by using the following code: |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2609 |
* <pre> |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2610 |
* System.setProperty("sun.awt.enableExtraMouseButtons", "true"); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2611 |
* </pre> |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2612 |
* before the {@code Toolkit} class initialization. |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2613 |
* If not set by the time of the {@code Toolkit} class initialization, this property will be |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2614 |
* initialized with {@code true}. |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2615 |
* Changing this value after the {@code Toolkit} class initialization will have no effect. |
23717 | 2616 |
* |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2617 |
* @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2618 |
* @return {@code true} if events from extra mouse buttons are allowed to be processed and posted; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2619 |
* {@code false} otherwise |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2620 |
* @see System#getProperty(String propertyName) |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2621 |
* @see System#setProperty(String propertyName, String value) |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2622 |
* @see java.awt.EventQueue |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2623 |
* @since 1.7 |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2624 |
*/ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2625 |
public boolean areExtraMouseButtonsEnabled() throws HeadlessException { |
9656
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
2626 |
GraphicsEnvironment.checkHeadless(); |
b9011986e4c8
7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents:
9475
diff
changeset
|
2627 |
|
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2628 |
return Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
2
diff
changeset
|
2629 |
} |
2 | 2630 |
} |