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