29 import java.io.ObjectInputStream;
30 import java.io.IOException;
31 import java.util.Iterator;
32 import java.util.concurrent.atomic.AtomicLong;
33 import java.security.AccessController;
34 import java.security.PrivilegedAction;
35 import javax.accessibility.*;
36 import sun.awt.AppContext;
37 import sun.awt.AWTPermissions;
38 import sun.awt.SunToolkit;
39 import sun.awt.util.IdentityArrayList;
40 import sun.awt.util.IdentityLinkedList;
41 import java.security.AccessControlException;
42
43 /**
44 * A Dialog is a top-level window with a title and a border
45 * that is typically used to take some form of input from the user.
46 *
47 * The size of the dialog includes any area designated for the
48 * border. The dimensions of the border area can be obtained
49 * using the <code>getInsets</code> method, however, since
50 * these dimensions are platform-dependent, a valid insets
51 * value cannot be obtained until the dialog is made displayable
52 * by either calling <code>pack</code> or <code>show</code>.
53 * Since the border area is included in the overall size of the
54 * dialog, the border effectively obscures a portion of the dialog,
55 * constraining the area available for rendering and/or displaying
56 * subcomponents to the rectangle which has an upper-left corner
57 * location of <code>(insets.left, insets.top)</code>, and has a size of
58 * <code>width - (insets.left + insets.right)</code> by
59 * <code>height - (insets.top + insets.bottom)</code>.
60 * <p>
61 * The default layout for a dialog is <code>BorderLayout</code>.
62 * <p>
63 * A dialog may have its native decorations (i.e. Frame & Titlebar) turned off
64 * with <code>setUndecorated</code>. This can only be done while the dialog
65 * is not {@link Component#isDisplayable() displayable}.
66 * <p>
67 * A dialog may have another window as its owner when it's constructed. When
68 * the owner window of a visible dialog is minimized, the dialog will
69 * automatically be hidden from the user. When the owner window is subsequently
70 * restored, the dialog is made visible to the user again.
71 * <p>
72 * In a multi-screen environment, you can create a <code>Dialog</code>
73 * on a different screen device than its owner. See {@link java.awt.Frame} for
74 * more information.
75 * <p>
76 * A dialog can be either modeless (the default) or modal. A modal
77 * dialog is one which blocks input to some other top-level windows
78 * in the application, except for any windows created with the dialog
79 * as their owner. See <a href="doc-files/Modality.html">AWT Modality</a>
80 * specification for details.
81 * <p>
82 * Dialogs are capable of generating the following
83 * <code>WindowEvents</code>:
84 * <code>WindowOpened</code>, <code>WindowClosing</code>,
85 * <code>WindowClosed</code>, <code>WindowActivated</code>,
86 * <code>WindowDeactivated</code>, <code>WindowGainedFocus</code>,
87 * <code>WindowLostFocus</code>.
88 *
89 * @see WindowEvent
90 * @see Window#addWindowListener
91 *
92 * @author Sami Shaio
93 * @author Arthur van Hoff
94 * @since 1.0
95 */
96 public class Dialog extends Window {
97
98 static {
99 /* ensure that the necessary native libraries are loaded */
100 Toolkit.loadLibraries();
101 if (!GraphicsEnvironment.isHeadless()) {
102 initIDs();
103 }
104 }
105
106 /**
107 * A dialog's resizable property. Will be true
108 * if the Dialog is to be resizable, otherwise
109 * it will be false.
110 *
111 * @serial
112 * @see #setResizable(boolean)
113 */
114 boolean resizable = true;
115
116
117 /**
118 * This field indicates whether the dialog is undecorated.
119 * This property can only be changed while the dialog is not displayable.
120 * <code>undecorated</code> will be true if the dialog is
121 * undecorated, otherwise it will be false.
122 *
123 * @serial
124 * @see #setUndecorated(boolean)
125 * @see #isUndecorated()
126 * @see Component#isDisplayable()
127 * @since 1.4
128 */
129 boolean undecorated = false;
130
131 private transient boolean initialized = false;
132
133 /**
134 * Modal dialogs block all input to some top-level windows.
135 * Whether a particular window is blocked depends on dialog's type
136 * of modality; this is called the "scope of blocking". The
137 * <code>ModalityType</code> enum specifies modal types and their
138 * associated scopes.
139 *
140 * @see Dialog#getModalityType
141 * @see Dialog#setModalityType
142 * @see Toolkit#isModalityTypeSupported
143 *
144 * @since 1.6
145 */
146 public static enum ModalityType {
147 /**
148 * <code>MODELESS</code> dialog doesn't block any top-level windows.
149 */
150 MODELESS,
151 /**
152 * A <code>DOCUMENT_MODAL</code> dialog blocks input to all top-level windows
153 * from the same document except those from its own child hierarchy.
154 * A document is a top-level window without an owner. It may contain child
155 * windows that, together with the top-level window are treated as a single
156 * solid document. Since every top-level window must belong to some
157 * document, its root can be found as the top-nearest window without an owner.
158 */
159 DOCUMENT_MODAL,
160 /**
161 * An <code>APPLICATION_MODAL</code> dialog blocks all top-level windows
162 * from the same Java application except those from its own child hierarchy.
163 * If there are several applets launched in a browser, they can be
164 * treated either as separate applications or a single one. This behavior
165 * is implementation-dependent.
166 */
167 APPLICATION_MODAL,
168 /**
169 * A <code>TOOLKIT_MODAL</code> dialog blocks all top-level windows run
170 * from the same toolkit except those from its own child hierarchy. If there
171 * are several applets launched in a browser, all of them run with the same
172 * toolkit; thus, a toolkit-modal dialog displayed by an applet may affect
173 * other applets and all windows of the browser instance which embeds the
174 * Java runtime environment for this toolkit.
175 * Special <code>AWTPermission</code> "toolkitModality" must be granted to use
176 * toolkit-modal dialogs. If a <code>TOOLKIT_MODAL</code> dialog is being created
177 * and this permission is not granted, a <code>SecurityException</code> will be
178 * thrown, and no dialog will be created. If a modality type is being changed
179 * to <code>TOOLKIT_MODAL</code> and this permission is not granted, a
180 * <code>SecurityException</code> will be thrown, and the modality type will
181 * be left unchanged.
182 */
183 TOOLKIT_MODAL
184 };
185
186 /**
187 * Default modality type for modal dialogs. The default modality type is
188 * <code>APPLICATION_MODAL</code>. Calling the oldstyle <code>setModal(true)</code>
189 * is equal to <code>setModalityType(DEFAULT_MODALITY_TYPE)</code>.
190 *
191 * @see java.awt.Dialog.ModalityType
192 * @see java.awt.Dialog#setModal
193 *
194 * @since 1.6
195 */
196 public static final ModalityType DEFAULT_MODALITY_TYPE = ModalityType.APPLICATION_MODAL;
197
198 /**
199 * True if this dialog is modal, false is the dialog is modeless.
200 * A modal dialog blocks user input to some application top-level
201 * windows. This field is kept only for backwards compatibility. Use the
202 * {@link Dialog.ModalityType ModalityType} enum instead.
203 *
204 * @serial
205 *
206 * @see #isModal
207 * @see #setModal
208 * @see #getModalityType
209 * @see #setModalityType
228 */
229 ModalityType modalityType;
230
231 /**
232 * Any top-level window can be marked not to be blocked by modal
233 * dialogs. This is called "modal exclusion". This enum specifies
234 * the possible modal exclusion types.
235 *
236 * @see Window#getModalExclusionType
237 * @see Window#setModalExclusionType
238 * @see Toolkit#isModalExclusionTypeSupported
239 *
240 * @since 1.6
241 */
242 public static enum ModalExclusionType {
243 /**
244 * No modal exclusion.
245 */
246 NO_EXCLUDE,
247 /**
248 * <code>APPLICATION_EXCLUDE</code> indicates that a top-level window
249 * won't be blocked by any application-modal dialogs. Also, it isn't
250 * blocked by document-modal dialogs from outside of its child hierarchy.
251 */
252 APPLICATION_EXCLUDE,
253 /**
254 * <code>TOOLKIT_EXCLUDE</code> indicates that a top-level window
255 * won't be blocked by application-modal or toolkit-modal dialogs. Also,
256 * it isn't blocked by document-modal dialogs from outside of its
257 * child hierarchy.
258 * The "toolkitModality" <code>AWTPermission</code> must be granted
259 * for this exclusion. If an exclusion property is being changed to
260 * <code>TOOLKIT_EXCLUDE</code> and this permission is not granted, a
261 * <code>SecurityException</code> will be thrown, and the exclusion
262 * property will be left unchanged.
263 */
264 TOOLKIT_EXCLUDE
265 };
266
267 /* operations with this list should be synchronized on tree lock*/
268 static transient IdentityArrayList<Dialog> modalDialogs = new IdentityArrayList<Dialog>();
269
270 transient IdentityArrayList<Window> blockedWindows = new IdentityArrayList<Window>();
271
272 /**
273 * Specifies the title of the Dialog.
274 * This field can be null.
275 *
276 * @serial
277 * @see #getTitle()
278 * @see #setTitle(String)
279 */
280 String title;
281
296 /*
297 * Indicates that this dialog is being disposed. This flag is set to true at
298 * the beginning of doDispose() and to false at the end of doDispose().
299 *
300 * @see #hide()
301 * @see #hideAndDisposePreHandler()
302 * @see #hideAndDisposeHandler()
303 * @see #doDispose()
304 */
305 transient volatile boolean isInDispose = false;
306
307 private static final String base = "dialog";
308 private static int nameCounter = 0;
309
310 /*
311 * JDK 1.1 serialVersionUID
312 */
313 private static final long serialVersionUID = 5920926903803293709L;
314
315 /**
316 * Constructs an initially invisible, modeless <code>Dialog</code> with
317 * the specified owner <code>Frame</code> and an empty title.
318 *
319 * @param owner the owner of the dialog or <code>null</code> if
320 * this dialog has no owner
321 * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
322 * <code>GraphicsConfiguration</code> is not from a screen device
323 * @exception HeadlessException when
324 * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
325 *
326 * @see java.awt.GraphicsEnvironment#isHeadless
327 * @see Component#setSize
328 * @see Component#setVisible
329 */
330 public Dialog(Frame owner) {
331 this(owner, "", false);
332 }
333
334 /**
335 * Constructs an initially invisible <code>Dialog</code> with the specified
336 * owner <code>Frame</code> and modality and an empty title.
337 *
338 * @param owner the owner of the dialog or <code>null</code> if
339 * this dialog has no owner
340 * @param modal specifies whether dialog blocks user input to other top-level
341 * windows when shown. If <code>false</code>, the dialog is <code>MODELESS</code>;
342 * if <code>true</code>, the modality type property is set to
343 * <code>DEFAULT_MODALITY_TYPE</code>
344 * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
345 * <code>GraphicsConfiguration</code> is not from a screen device
346 * @exception HeadlessException when
347 * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
348 *
349 * @see java.awt.Dialog.ModalityType
350 * @see java.awt.Dialog.ModalityType#MODELESS
351 * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
352 * @see java.awt.Dialog#setModal
353 * @see java.awt.Dialog#setModalityType
354 * @see java.awt.GraphicsEnvironment#isHeadless
355 */
356 public Dialog(Frame owner, boolean modal) {
357 this(owner, "", modal);
358 }
359
360 /**
361 * Constructs an initially invisible, modeless <code>Dialog</code> with
362 * the specified owner <code>Frame</code> and title.
363 *
364 * @param owner the owner of the dialog or <code>null</code> if
365 * this dialog has no owner
366 * @param title the title of the dialog or <code>null</code> if this dialog
367 * has no title
368 * @exception IllegalArgumentException if the <code>owner</code>'s
369 * <code>GraphicsConfiguration</code> is not from a screen device
370 * @exception HeadlessException when
371 * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
372 *
373 * @see java.awt.GraphicsEnvironment#isHeadless
374 * @see Component#setSize
375 * @see Component#setVisible
376 */
377 public Dialog(Frame owner, String title) {
378 this(owner, title, false);
379 }
380
381 /**
382 * Constructs an initially invisible <code>Dialog</code> with the
383 * specified owner <code>Frame</code>, title and modality.
384 *
385 * @param owner the owner of the dialog or <code>null</code> if
386 * this dialog has no owner
387 * @param title the title of the dialog or <code>null</code> if this dialog
388 * has no title
389 * @param modal specifies whether dialog blocks user input to other top-level
390 * windows when shown. If <code>false</code>, the dialog is <code>MODELESS</code>;
391 * if <code>true</code>, the modality type property is set to
392 * <code>DEFAULT_MODALITY_TYPE</code>
393 * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
394 * <code>GraphicsConfiguration</code> is not from a screen device
395 * @exception HeadlessException when
396 * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
397 *
398 * @see java.awt.Dialog.ModalityType
399 * @see java.awt.Dialog.ModalityType#MODELESS
400 * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
401 * @see java.awt.Dialog#setModal
402 * @see java.awt.Dialog#setModalityType
403 * @see java.awt.GraphicsEnvironment#isHeadless
404 * @see Component#setSize
405 * @see Component#setVisible
406 */
407 public Dialog(Frame owner, String title, boolean modal) {
408 this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS);
409 }
410
411 /**
412 * Constructs an initially invisible <code>Dialog</code> with the specified owner
413 * <code>Frame</code>, title, modality, and <code>GraphicsConfiguration</code>.
414 * @param owner the owner of the dialog or <code>null</code> if this dialog
415 * has no owner
416 * @param title the title of the dialog or <code>null</code> if this dialog
417 * has no title
418 * @param modal specifies whether dialog blocks user input to other top-level
419 * windows when shown. If <code>false</code>, the dialog is <code>MODELESS</code>;
420 * if <code>true</code>, the modality type property is set to
421 * <code>DEFAULT_MODALITY_TYPE</code>
422 * @param gc the <code>GraphicsConfiguration</code> of the target screen device;
423 * if <code>null</code>, the default system <code>GraphicsConfiguration</code>
424 * is assumed
425 * @exception java.lang.IllegalArgumentException if <code>gc</code>
426 * is not from a screen device
427 * @exception HeadlessException when
428 * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
429 *
430 * @see java.awt.Dialog.ModalityType
431 * @see java.awt.Dialog.ModalityType#MODELESS
432 * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
433 * @see java.awt.Dialog#setModal
434 * @see java.awt.Dialog#setModalityType
435 * @see java.awt.GraphicsEnvironment#isHeadless
436 * @see Component#setSize
437 * @see Component#setVisible
438 * @since 1.4
439 */
440 public Dialog(Frame owner, String title, boolean modal,
441 GraphicsConfiguration gc) {
442 this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS, gc);
443 }
444
445 /**
446 * Constructs an initially invisible, modeless <code>Dialog</code> with
447 * the specified owner <code>Dialog</code> and an empty title.
448 *
449 * @param owner the owner of the dialog or <code>null</code> if this
450 * dialog has no owner
451 * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
452 * <code>GraphicsConfiguration</code> is not from a screen device
453 * @exception HeadlessException when
454 * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
455 * @see java.awt.GraphicsEnvironment#isHeadless
456 * @since 1.2
457 */
458 public Dialog(Dialog owner) {
459 this(owner, "", false);
460 }
461
462 /**
463 * Constructs an initially invisible, modeless <code>Dialog</code>
464 * with the specified owner <code>Dialog</code> and title.
465 *
466 * @param owner the owner of the dialog or <code>null</code> if this
467 * has no owner
468 * @param title the title of the dialog or <code>null</code> if this dialog
469 * has no title
470 * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
471 * <code>GraphicsConfiguration</code> is not from a screen device
472 * @exception HeadlessException when
473 * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
474 *
475 * @see java.awt.GraphicsEnvironment#isHeadless
476 * @since 1.2
477 */
478 public Dialog(Dialog owner, String title) {
479 this(owner, title, false);
480 }
481
482 /**
483 * Constructs an initially invisible <code>Dialog</code> with the
484 * specified owner <code>Dialog</code>, title, and modality.
485 *
486 * @param owner the owner of the dialog or <code>null</code> if this
487 * dialog has no owner
488 * @param title the title of the dialog or <code>null</code> if this
489 * dialog has no title
490 * @param modal specifies whether dialog blocks user input to other top-level
491 * windows when shown. If <code>false</code>, the dialog is <code>MODELESS</code>;
492 * if <code>true</code>, the modality type property is set to
493 * <code>DEFAULT_MODALITY_TYPE</code>
494 * @exception IllegalArgumentException if the <code>owner</code>'s
495 * <code>GraphicsConfiguration</code> is not from a screen device
496 * @exception HeadlessException when
497 * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
498 *
499 * @see java.awt.Dialog.ModalityType
500 * @see java.awt.Dialog.ModalityType#MODELESS
501 * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
502 * @see java.awt.Dialog#setModal
503 * @see java.awt.Dialog#setModalityType
504 * @see java.awt.GraphicsEnvironment#isHeadless
505 *
506 * @since 1.2
507 */
508 public Dialog(Dialog owner, String title, boolean modal) {
509 this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS);
510 }
511
512 /**
513 * Constructs an initially invisible <code>Dialog</code> with the
514 * specified owner <code>Dialog</code>, title, modality and
515 * <code>GraphicsConfiguration</code>.
516 *
517 * @param owner the owner of the dialog or <code>null</code> if this
518 * dialog has no owner
519 * @param title the title of the dialog or <code>null</code> if this
520 * dialog has no title
521 * @param modal specifies whether dialog blocks user input to other top-level
522 * windows when shown. If <code>false</code>, the dialog is <code>MODELESS</code>;
523 * if <code>true</code>, the modality type property is set to
524 * <code>DEFAULT_MODALITY_TYPE</code>
525 * @param gc the <code>GraphicsConfiguration</code> of the target screen device;
526 * if <code>null</code>, the default system <code>GraphicsConfiguration</code>
527 * is assumed
528 * @exception java.lang.IllegalArgumentException if <code>gc</code>
529 * is not from a screen device
530 * @exception HeadlessException when
531 * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
532 *
533 * @see java.awt.Dialog.ModalityType
534 * @see java.awt.Dialog.ModalityType#MODELESS
535 * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
536 * @see java.awt.Dialog#setModal
537 * @see java.awt.Dialog#setModalityType
538 * @see java.awt.GraphicsEnvironment#isHeadless
539 * @see Component#setSize
540 * @see Component#setVisible
541 *
542 * @since 1.4
543 */
544 public Dialog(Dialog owner, String title, boolean modal,
545 GraphicsConfiguration gc) {
546 this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS, gc);
547 }
548
549 /**
550 * Constructs an initially invisible, modeless <code>Dialog</code> with the
551 * specified owner <code>Window</code> and an empty title.
552 *
553 * @param owner the owner of the dialog. The owner must be an instance of
554 * {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
555 * of their descendants or <code>null</code>
556 *
557 * @exception java.lang.IllegalArgumentException if the <code>owner</code>
558 * is not an instance of {@link java.awt.Dialog Dialog} or {@link
559 * java.awt.Frame Frame}
560 * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
561 * <code>GraphicsConfiguration</code> is not from a screen device
562 * @exception HeadlessException when
563 * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
564 *
565 * @see java.awt.GraphicsEnvironment#isHeadless
566 *
567 * @since 1.6
568 */
569 public Dialog(Window owner) {
570 this(owner, "", ModalityType.MODELESS);
571 }
572
573 /**
574 * Constructs an initially invisible, modeless <code>Dialog</code> with
575 * the specified owner <code>Window</code> and title.
576 *
577 * @param owner the owner of the dialog. The owner must be an instance of
578 * {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
579 * of their descendants or <code>null</code>
580 * @param title the title of the dialog or <code>null</code> if this dialog
581 * has no title
582 *
583 * @exception java.lang.IllegalArgumentException if the <code>owner</code>
584 * is not an instance of {@link java.awt.Dialog Dialog} or {@link
585 * java.awt.Frame Frame}
586 * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
587 * <code>GraphicsConfiguration</code> is not from a screen device
588 * @exception HeadlessException when
589 * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
590 *
591 * @see java.awt.GraphicsEnvironment#isHeadless
592 *
593 * @since 1.6
594 */
595 public Dialog(Window owner, String title) {
596 this(owner, title, ModalityType.MODELESS);
597 }
598
599 /**
600 * Constructs an initially invisible <code>Dialog</code> with the
601 * specified owner <code>Window</code> and modality and an empty title.
602 *
603 * @param owner the owner of the dialog. The owner must be an instance of
604 * {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
605 * of their descendants or <code>null</code>
606 * @param modalityType specifies whether dialog blocks input to other
607 * windows when shown. <code>null</code> value and unsupported modality
608 * types are equivalent to <code>MODELESS</code>
609 *
610 * @exception java.lang.IllegalArgumentException if the <code>owner</code>
611 * is not an instance of {@link java.awt.Dialog Dialog} or {@link
612 * java.awt.Frame Frame}
613 * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
614 * <code>GraphicsConfiguration</code> is not from a screen device
615 * @exception HeadlessException when
616 * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
617 * @exception SecurityException if the calling thread does not have permission
618 * to create modal dialogs with the given <code>modalityType</code>
619 *
620 * @see java.awt.Dialog.ModalityType
621 * @see java.awt.Dialog#setModal
622 * @see java.awt.Dialog#setModalityType
623 * @see java.awt.GraphicsEnvironment#isHeadless
624 * @see java.awt.Toolkit#isModalityTypeSupported
625 *
626 * @since 1.6
627 */
628 public Dialog(Window owner, ModalityType modalityType) {
629 this(owner, "", modalityType);
630 }
631
632 /**
633 * Constructs an initially invisible <code>Dialog</code> with the
634 * specified owner <code>Window</code>, title and modality.
635 *
636 * @param owner the owner of the dialog. The owner must be an instance of
637 * {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
638 * of their descendants or <code>null</code>
639 * @param title the title of the dialog or <code>null</code> if this dialog
640 * has no title
641 * @param modalityType specifies whether dialog blocks input to other
642 * windows when shown. <code>null</code> value and unsupported modality
643 * types are equivalent to <code>MODELESS</code>
644 *
645 * @exception java.lang.IllegalArgumentException if the <code>owner</code>
646 * is not an instance of {@link java.awt.Dialog Dialog} or {@link
647 * java.awt.Frame Frame}
648 * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
649 * <code>GraphicsConfiguration</code> is not from a screen device
650 * @exception HeadlessException when
651 * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
652 * @exception SecurityException if the calling thread does not have permission
653 * to create modal dialogs with the given <code>modalityType</code>
654 *
655 * @see java.awt.Dialog.ModalityType
656 * @see java.awt.Dialog#setModal
657 * @see java.awt.Dialog#setModalityType
658 * @see java.awt.GraphicsEnvironment#isHeadless
659 * @see java.awt.Toolkit#isModalityTypeSupported
660 *
661 * @since 1.6
662 */
663 public Dialog(Window owner, String title, ModalityType modalityType) {
664 super(owner);
665
666 if ((owner != null) &&
667 !(owner instanceof Frame) &&
668 !(owner instanceof Dialog))
669 {
670 throw new IllegalArgumentException("Wrong parent window");
671 }
672
673 this.title = title;
674 setModalityType(modalityType);
675 SunToolkit.checkAndSetPolicy(this);
676 initialized = true;
677 }
678
679 /**
680 * Constructs an initially invisible <code>Dialog</code> with the
681 * specified owner <code>Window</code>, title, modality and
682 * <code>GraphicsConfiguration</code>.
683 *
684 * @param owner the owner of the dialog. The owner must be an instance of
685 * {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
686 * of their descendants or <code>null</code>
687 * @param title the title of the dialog or <code>null</code> if this dialog
688 * has no title
689 * @param modalityType specifies whether dialog blocks input to other
690 * windows when shown. <code>null</code> value and unsupported modality
691 * types are equivalent to <code>MODELESS</code>
692 * @param gc the <code>GraphicsConfiguration</code> of the target screen device;
693 * if <code>null</code>, the default system <code>GraphicsConfiguration</code>
694 * is assumed
695 *
696 * @exception java.lang.IllegalArgumentException if the <code>owner</code>
697 * is not an instance of {@link java.awt.Dialog Dialog} or {@link
698 * java.awt.Frame Frame}
699 * @exception java.lang.IllegalArgumentException if <code>gc</code>
700 * is not from a screen device
701 * @exception HeadlessException when
702 * <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
703 * @exception SecurityException if the calling thread does not have permission
704 * to create modal dialogs with the given <code>modalityType</code>
705 *
706 * @see java.awt.Dialog.ModalityType
707 * @see java.awt.Dialog#setModal
708 * @see java.awt.Dialog#setModalityType
709 * @see java.awt.GraphicsEnvironment#isHeadless
710 * @see java.awt.Toolkit#isModalityTypeSupported
711 *
712 * @since 1.6
713 */
714 public Dialog(Window owner, String title, ModalityType modalityType,
715 GraphicsConfiguration gc) {
716 super(owner, gc);
717
718 if ((owner != null) &&
719 !(owner instanceof Frame) &&
720 !(owner instanceof Dialog))
721 {
722 throw new IllegalArgumentException("wrong owner window");
723 }
724
749 */
750 public void addNotify() {
751 synchronized (getTreeLock()) {
752 if (parent != null && parent.peer == null) {
753 parent.addNotify();
754 }
755
756 if (peer == null) {
757 peer = getComponentFactory().createDialog(this);
758 }
759 super.addNotify();
760 }
761 }
762
763 /**
764 * Indicates whether the dialog is modal.
765 * <p>
766 * This method is obsolete and is kept for backwards compatibility only.
767 * Use {@link #getModalityType getModalityType()} instead.
768 *
769 * @return <code>true</code> if this dialog window is modal;
770 * <code>false</code> otherwise
771 *
772 * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
773 * @see java.awt.Dialog.ModalityType#MODELESS
774 * @see java.awt.Dialog#setModal
775 * @see java.awt.Dialog#getModalityType
776 * @see java.awt.Dialog#setModalityType
777 */
778 public boolean isModal() {
779 return isModal_NoClientCode();
780 }
781 final boolean isModal_NoClientCode() {
782 return modalityType != ModalityType.MODELESS;
783 }
784
785 /**
786 * Specifies whether this dialog should be modal.
787 * <p>
788 * This method is obsolete and is kept for backwards compatibility only.
789 * Use {@link #setModalityType setModalityType()} instead.
790 * <p>
791 * Note: changing modality of the visible dialog may have no effect
792 * until it is hidden and then shown again.
793 *
794 * @param modal specifies whether dialog blocks input to other windows
795 * when shown; calling to <code>setModal(true)</code> is equivalent to
796 * <code>setModalityType(Dialog.DEFAULT_MODALITY_TYPE)</code>, and
797 * calling to <code>setModal(false)</code> is equivalent to
798 * <code>setModalityType(Dialog.ModalityType.MODELESS)</code>
799 *
800 * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
801 * @see java.awt.Dialog.ModalityType#MODELESS
802 * @see java.awt.Dialog#isModal
803 * @see java.awt.Dialog#getModalityType
804 * @see java.awt.Dialog#setModalityType
805 *
806 * @since 1.1
807 */
808 public void setModal(boolean modal) {
809 this.modal = modal;
810 setModalityType(modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS);
811 }
812
813 /**
814 * Returns the modality type of this dialog.
815 *
816 * @return modality type of this dialog
817 *
818 * @see java.awt.Dialog#setModalityType
819 *
820 * @since 1.6
821 */
822 public ModalityType getModalityType() {
823 return modalityType;
824 }
825
826 /**
827 * Sets the modality type for this dialog. See {@link
828 * java.awt.Dialog.ModalityType ModalityType} for possible modality types.
829 * <p>
830 * If the given modality type is not supported, <code>MODELESS</code>
831 * is used. You may want to call <code>getModalityType()</code> after calling
832 * this method to ensure that the modality type has been set.
833 * <p>
834 * Note: changing modality of the visible dialog may have no effect
835 * until it is hidden and then shown again.
836 *
837 * @param type specifies whether dialog blocks input to other
838 * windows when shown. <code>null</code> value and unsupported modality
839 * types are equivalent to <code>MODELESS</code>
840 * @exception SecurityException if the calling thread does not have permission
841 * to create modal dialogs with the given <code>modalityType</code>
842 *
843 * @see java.awt.Dialog#getModalityType
844 * @see java.awt.Toolkit#isModalityTypeSupported
845 *
846 * @since 1.6
847 */
848 public void setModalityType(ModalityType type) {
849 if (type == null) {
850 type = Dialog.ModalityType.MODELESS;
851 }
852 if (!Toolkit.getDefaultToolkit().isModalityTypeSupported(type)) {
853 type = Dialog.ModalityType.MODELESS;
854 }
855 if (modalityType == type) {
856 return;
857 }
858
859 checkModalityPermission(type);
860
861 modalityType = type;
862 modal = (modalityType != ModalityType.MODELESS);
863 }
864
865 /**
866 * Gets the title of the dialog. The title is displayed in the
867 * dialog's border.
868 * @return the title of this dialog window. The title may be
869 * <code>null</code>.
870 * @see java.awt.Dialog#setTitle
871 */
872 public String getTitle() {
873 return title;
874 }
875
876 /**
877 * Sets the title of the Dialog.
878 * @param title the title displayed in the dialog's border;
879 * a null value results in an empty title
880 * @see #getTitle
881 */
882 public void setTitle(String title) {
883 String oldTitle = this.title;
884
885 synchronized(this) {
886 this.title = title;
887 DialogPeer peer = (DialogPeer)this.peer;
888 if (peer != null) {
889 peer.setTitle(title);
1176 * <p>
1177 * If this dialog is modal and blocks some windows, then all of them are
1178 * also sent to the back to keep them below the blocking dialog.
1179 *
1180 * @see java.awt.Window#toBack
1181 */
1182 public void toBack() {
1183 super.toBack();
1184 if (visible) {
1185 synchronized (getTreeLock()) {
1186 for (Window w : blockedWindows) {
1187 w.toBack_NoClientCode();
1188 }
1189 }
1190 }
1191 }
1192
1193 /**
1194 * Indicates whether this dialog is resizable by the user.
1195 * By default, all dialogs are initially resizable.
1196 * @return <code>true</code> if the user can resize the dialog;
1197 * <code>false</code> otherwise.
1198 * @see java.awt.Dialog#setResizable
1199 */
1200 public boolean isResizable() {
1201 return resizable;
1202 }
1203
1204 /**
1205 * Sets whether this dialog is resizable by the user.
1206 * @param resizable <code>true</code> if the user can
1207 * resize this dialog; <code>false</code> otherwise.
1208 * @see java.awt.Dialog#isResizable
1209 */
1210 public void setResizable(boolean resizable) {
1211 boolean testvalid = false;
1212
1213 synchronized (this) {
1214 this.resizable = resizable;
1215 DialogPeer peer = (DialogPeer)this.peer;
1216 if (peer != null) {
1217 peer.setResizable(resizable);
1218 testvalid = true;
1219 }
1220 }
1221
1222 // On some platforms, changing the resizable state affects
1223 // the insets of the Dialog. If we could, we'd call invalidate()
1224 // from the peer, but we need to guarantee that we're not holding
1225 // the Dialog lock when we call invalidate().
1226 if (testvalid) {
1227 invalidateIfValid();
1266 }
1267 if (!undecorated) {
1268 if (getOpacity() < 1.0f) {
1269 throw new IllegalComponentStateException("The dialog is not opaque");
1270 }
1271 if (getShape() != null) {
1272 throw new IllegalComponentStateException("The dialog does not have a default shape");
1273 }
1274 Color bg = getBackground();
1275 if ((bg != null) && (bg.getAlpha() < 255)) {
1276 throw new IllegalComponentStateException("The dialog background color is not opaque");
1277 }
1278 }
1279 this.undecorated = undecorated;
1280 }
1281 }
1282
1283 /**
1284 * Indicates whether this dialog is undecorated.
1285 * By default, all dialogs are initially decorated.
1286 * @return <code>true</code> if dialog is undecorated;
1287 * <code>false</code> otherwise.
1288 * @see java.awt.Dialog#setUndecorated
1289 * @since 1.4
1290 */
1291 public boolean isUndecorated() {
1292 return undecorated;
1293 }
1294
1295 /**
1296 * {@inheritDoc}
1297 */
1298 @Override
1299 public void setOpacity(float opacity) {
1300 synchronized (getTreeLock()) {
1301 if ((opacity < 1.0f) && !isUndecorated()) {
1302 throw new IllegalComponentStateException("The dialog is decorated");
1303 }
1304 super.setOpacity(opacity);
1305 }
1306 }
1307
1319 }
1320
1321 /**
1322 * {@inheritDoc}
1323 */
1324 @Override
1325 public void setBackground(Color bgColor) {
1326 synchronized (getTreeLock()) {
1327 if ((bgColor != null) && (bgColor.getAlpha() < 255) && !isUndecorated()) {
1328 throw new IllegalComponentStateException("The dialog is decorated");
1329 }
1330 super.setBackground(bgColor);
1331 }
1332 }
1333
1334 /**
1335 * Returns a string representing the state of this dialog. This
1336 * method is intended to be used only for debugging purposes, and the
1337 * content and format of the returned string may vary between
1338 * implementations. The returned string may be empty but may not be
1339 * <code>null</code>.
1340 *
1341 * @return the parameter string of this dialog window.
1342 */
1343 protected String paramString() {
1344 String str = super.paramString() + "," + modalityType;
1345 if (title != null) {
1346 str += ",title=" + title;
1347 }
1348 return str;
1349 }
1350
1351 /**
1352 * Initialize JNI field and method IDs
1353 */
1354 private static native void initIDs();
1355
1356 /*
1357 * --- Modality support ---
1358 *
1359 */
1630
1631 /**
1632 * Gets the AccessibleContext associated with this Dialog.
1633 * For dialogs, the AccessibleContext takes the form of an
1634 * AccessibleAWTDialog.
1635 * A new AccessibleAWTDialog instance is created if necessary.
1636 *
1637 * @return an AccessibleAWTDialog that serves as the
1638 * AccessibleContext of this Dialog
1639 * @since 1.3
1640 */
1641 public AccessibleContext getAccessibleContext() {
1642 if (accessibleContext == null) {
1643 accessibleContext = new AccessibleAWTDialog();
1644 }
1645 return accessibleContext;
1646 }
1647
1648 /**
1649 * This class implements accessibility support for the
1650 * <code>Dialog</code> class. It provides an implementation of the
1651 * Java Accessibility API appropriate to dialog user-interface elements.
1652 * @since 1.3
1653 */
1654 protected class AccessibleAWTDialog extends AccessibleAWTWindow
1655 {
1656 /*
1657 * JDK 1.3 serialVersionUID
1658 */
1659 private static final long serialVersionUID = 4837230331833941201L;
1660
1661 /**
1662 * Get the role of this object.
1663 *
1664 * @return an instance of AccessibleRole describing the role of the
1665 * object
1666 * @see AccessibleRole
1667 */
1668 public AccessibleRole getAccessibleRole() {
1669 return AccessibleRole.DIALOG;
1670 }
|
29 import java.io.ObjectInputStream;
30 import java.io.IOException;
31 import java.util.Iterator;
32 import java.util.concurrent.atomic.AtomicLong;
33 import java.security.AccessController;
34 import java.security.PrivilegedAction;
35 import javax.accessibility.*;
36 import sun.awt.AppContext;
37 import sun.awt.AWTPermissions;
38 import sun.awt.SunToolkit;
39 import sun.awt.util.IdentityArrayList;
40 import sun.awt.util.IdentityLinkedList;
41 import java.security.AccessControlException;
42
43 /**
44 * A Dialog is a top-level window with a title and a border
45 * that is typically used to take some form of input from the user.
46 *
47 * The size of the dialog includes any area designated for the
48 * border. The dimensions of the border area can be obtained
49 * using the {@code getInsets} method, however, since
50 * these dimensions are platform-dependent, a valid insets
51 * value cannot be obtained until the dialog is made displayable
52 * by either calling {@code pack} or {@code show}.
53 * Since the border area is included in the overall size of the
54 * dialog, the border effectively obscures a portion of the dialog,
55 * constraining the area available for rendering and/or displaying
56 * subcomponents to the rectangle which has an upper-left corner
57 * location of {@code (insets.left, insets.top)}, and has a size of
58 * {@code width - (insets.left + insets.right)} by
59 * {@code height - (insets.top + insets.bottom)}.
60 * <p>
61 * The default layout for a dialog is {@code BorderLayout}.
62 * <p>
63 * A dialog may have its native decorations (i.e. Frame & Titlebar) turned off
64 * with {@code setUndecorated}. This can only be done while the dialog
65 * is not {@link Component#isDisplayable() displayable}.
66 * <p>
67 * A dialog may have another window as its owner when it's constructed. When
68 * the owner window of a visible dialog is minimized, the dialog will
69 * automatically be hidden from the user. When the owner window is subsequently
70 * restored, the dialog is made visible to the user again.
71 * <p>
72 * In a multi-screen environment, you can create a {@code Dialog}
73 * on a different screen device than its owner. See {@link java.awt.Frame} for
74 * more information.
75 * <p>
76 * A dialog can be either modeless (the default) or modal. A modal
77 * dialog is one which blocks input to some other top-level windows
78 * in the application, except for any windows created with the dialog
79 * as their owner. See <a href="doc-files/Modality.html">AWT Modality</a>
80 * specification for details.
81 * <p>
82 * Dialogs are capable of generating the following
83 * {@code WindowEvents}:
84 * {@code WindowOpened}, {@code WindowClosing},
85 * {@code WindowClosed}, {@code WindowActivated},
86 * {@code WindowDeactivated}, {@code WindowGainedFocus},
87 * {@code WindowLostFocus}.
88 *
89 * @see WindowEvent
90 * @see Window#addWindowListener
91 *
92 * @author Sami Shaio
93 * @author Arthur van Hoff
94 * @since 1.0
95 */
96 public class Dialog extends Window {
97
98 static {
99 /* ensure that the necessary native libraries are loaded */
100 Toolkit.loadLibraries();
101 if (!GraphicsEnvironment.isHeadless()) {
102 initIDs();
103 }
104 }
105
106 /**
107 * A dialog's resizable property. Will be true
108 * if the Dialog is to be resizable, otherwise
109 * it will be false.
110 *
111 * @serial
112 * @see #setResizable(boolean)
113 */
114 boolean resizable = true;
115
116
117 /**
118 * This field indicates whether the dialog is undecorated.
119 * This property can only be changed while the dialog is not displayable.
120 * {@code undecorated} will be true if the dialog is
121 * undecorated, otherwise it will be false.
122 *
123 * @serial
124 * @see #setUndecorated(boolean)
125 * @see #isUndecorated()
126 * @see Component#isDisplayable()
127 * @since 1.4
128 */
129 boolean undecorated = false;
130
131 private transient boolean initialized = false;
132
133 /**
134 * Modal dialogs block all input to some top-level windows.
135 * Whether a particular window is blocked depends on dialog's type
136 * of modality; this is called the "scope of blocking". The
137 * {@code ModalityType} enum specifies modal types and their
138 * associated scopes.
139 *
140 * @see Dialog#getModalityType
141 * @see Dialog#setModalityType
142 * @see Toolkit#isModalityTypeSupported
143 *
144 * @since 1.6
145 */
146 public static enum ModalityType {
147 /**
148 * {@code MODELESS} dialog doesn't block any top-level windows.
149 */
150 MODELESS,
151 /**
152 * A {@code DOCUMENT_MODAL} dialog blocks input to all top-level windows
153 * from the same document except those from its own child hierarchy.
154 * A document is a top-level window without an owner. It may contain child
155 * windows that, together with the top-level window are treated as a single
156 * solid document. Since every top-level window must belong to some
157 * document, its root can be found as the top-nearest window without an owner.
158 */
159 DOCUMENT_MODAL,
160 /**
161 * An {@code APPLICATION_MODAL} dialog blocks all top-level windows
162 * from the same Java application except those from its own child hierarchy.
163 * If there are several applets launched in a browser, they can be
164 * treated either as separate applications or a single one. This behavior
165 * is implementation-dependent.
166 */
167 APPLICATION_MODAL,
168 /**
169 * A {@code TOOLKIT_MODAL} dialog blocks all top-level windows run
170 * from the same toolkit except those from its own child hierarchy. If there
171 * are several applets launched in a browser, all of them run with the same
172 * toolkit; thus, a toolkit-modal dialog displayed by an applet may affect
173 * other applets and all windows of the browser instance which embeds the
174 * Java runtime environment for this toolkit.
175 * Special {@code AWTPermission} "toolkitModality" must be granted to use
176 * toolkit-modal dialogs. If a {@code TOOLKIT_MODAL} dialog is being created
177 * and this permission is not granted, a {@code SecurityException} will be
178 * thrown, and no dialog will be created. If a modality type is being changed
179 * to {@code TOOLKIT_MODAL} and this permission is not granted, a
180 * {@code SecurityException} will be thrown, and the modality type will
181 * be left unchanged.
182 */
183 TOOLKIT_MODAL
184 };
185
186 /**
187 * Default modality type for modal dialogs. The default modality type is
188 * {@code APPLICATION_MODAL}. Calling the oldstyle {@code setModal(true)}
189 * is equal to {@code setModalityType(DEFAULT_MODALITY_TYPE)}.
190 *
191 * @see java.awt.Dialog.ModalityType
192 * @see java.awt.Dialog#setModal
193 *
194 * @since 1.6
195 */
196 public static final ModalityType DEFAULT_MODALITY_TYPE = ModalityType.APPLICATION_MODAL;
197
198 /**
199 * True if this dialog is modal, false is the dialog is modeless.
200 * A modal dialog blocks user input to some application top-level
201 * windows. This field is kept only for backwards compatibility. Use the
202 * {@link Dialog.ModalityType ModalityType} enum instead.
203 *
204 * @serial
205 *
206 * @see #isModal
207 * @see #setModal
208 * @see #getModalityType
209 * @see #setModalityType
228 */
229 ModalityType modalityType;
230
231 /**
232 * Any top-level window can be marked not to be blocked by modal
233 * dialogs. This is called "modal exclusion". This enum specifies
234 * the possible modal exclusion types.
235 *
236 * @see Window#getModalExclusionType
237 * @see Window#setModalExclusionType
238 * @see Toolkit#isModalExclusionTypeSupported
239 *
240 * @since 1.6
241 */
242 public static enum ModalExclusionType {
243 /**
244 * No modal exclusion.
245 */
246 NO_EXCLUDE,
247 /**
248 * {@code APPLICATION_EXCLUDE} indicates that a top-level window
249 * won't be blocked by any application-modal dialogs. Also, it isn't
250 * blocked by document-modal dialogs from outside of its child hierarchy.
251 */
252 APPLICATION_EXCLUDE,
253 /**
254 * {@code TOOLKIT_EXCLUDE} indicates that a top-level window
255 * won't be blocked by application-modal or toolkit-modal dialogs. Also,
256 * it isn't blocked by document-modal dialogs from outside of its
257 * child hierarchy.
258 * The "toolkitModality" {@code AWTPermission} must be granted
259 * for this exclusion. If an exclusion property is being changed to
260 * {@code TOOLKIT_EXCLUDE} and this permission is not granted, a
261 * {@code SecurityException} will be thrown, and the exclusion
262 * property will be left unchanged.
263 */
264 TOOLKIT_EXCLUDE
265 };
266
267 /* operations with this list should be synchronized on tree lock*/
268 static transient IdentityArrayList<Dialog> modalDialogs = new IdentityArrayList<Dialog>();
269
270 transient IdentityArrayList<Window> blockedWindows = new IdentityArrayList<Window>();
271
272 /**
273 * Specifies the title of the Dialog.
274 * This field can be null.
275 *
276 * @serial
277 * @see #getTitle()
278 * @see #setTitle(String)
279 */
280 String title;
281
296 /*
297 * Indicates that this dialog is being disposed. This flag is set to true at
298 * the beginning of doDispose() and to false at the end of doDispose().
299 *
300 * @see #hide()
301 * @see #hideAndDisposePreHandler()
302 * @see #hideAndDisposeHandler()
303 * @see #doDispose()
304 */
305 transient volatile boolean isInDispose = false;
306
307 private static final String base = "dialog";
308 private static int nameCounter = 0;
309
310 /*
311 * JDK 1.1 serialVersionUID
312 */
313 private static final long serialVersionUID = 5920926903803293709L;
314
315 /**
316 * Constructs an initially invisible, modeless {@code Dialog} with
317 * the specified owner {@code Frame} and an empty title.
318 *
319 * @param owner the owner of the dialog or {@code null} if
320 * this dialog has no owner
321 * @exception java.lang.IllegalArgumentException if the {@code owner}'s
322 * {@code GraphicsConfiguration} is not from a screen device
323 * @exception HeadlessException when
324 * {@code GraphicsEnvironment.isHeadless()} returns {@code true}
325 *
326 * @see java.awt.GraphicsEnvironment#isHeadless
327 * @see Component#setSize
328 * @see Component#setVisible
329 */
330 public Dialog(Frame owner) {
331 this(owner, "", false);
332 }
333
334 /**
335 * Constructs an initially invisible {@code Dialog} with the specified
336 * owner {@code Frame} and modality and an empty title.
337 *
338 * @param owner the owner of the dialog or {@code null} if
339 * this dialog has no owner
340 * @param modal specifies whether dialog blocks user input to other top-level
341 * windows when shown. If {@code false}, the dialog is {@code MODELESS};
342 * if {@code true}, the modality type property is set to
343 * {@code DEFAULT_MODALITY_TYPE}
344 * @exception java.lang.IllegalArgumentException if the {@code owner}'s
345 * {@code GraphicsConfiguration} is not from a screen device
346 * @exception HeadlessException when
347 * {@code GraphicsEnvironment.isHeadless()} returns {@code true}
348 *
349 * @see java.awt.Dialog.ModalityType
350 * @see java.awt.Dialog.ModalityType#MODELESS
351 * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
352 * @see java.awt.Dialog#setModal
353 * @see java.awt.Dialog#setModalityType
354 * @see java.awt.GraphicsEnvironment#isHeadless
355 */
356 public Dialog(Frame owner, boolean modal) {
357 this(owner, "", modal);
358 }
359
360 /**
361 * Constructs an initially invisible, modeless {@code Dialog} with
362 * the specified owner {@code Frame} and title.
363 *
364 * @param owner the owner of the dialog or {@code null} if
365 * this dialog has no owner
366 * @param title the title of the dialog or {@code null} if this dialog
367 * has no title
368 * @exception IllegalArgumentException if the {@code owner}'s
369 * {@code GraphicsConfiguration} is not from a screen device
370 * @exception HeadlessException when
371 * {@code GraphicsEnvironment.isHeadless()} returns {@code true}
372 *
373 * @see java.awt.GraphicsEnvironment#isHeadless
374 * @see Component#setSize
375 * @see Component#setVisible
376 */
377 public Dialog(Frame owner, String title) {
378 this(owner, title, false);
379 }
380
381 /**
382 * Constructs an initially invisible {@code Dialog} with the
383 * specified owner {@code Frame}, title and modality.
384 *
385 * @param owner the owner of the dialog or {@code null} if
386 * this dialog has no owner
387 * @param title the title of the dialog or {@code null} if this dialog
388 * has no title
389 * @param modal specifies whether dialog blocks user input to other top-level
390 * windows when shown. If {@code false}, the dialog is {@code MODELESS};
391 * if {@code true}, the modality type property is set to
392 * {@code DEFAULT_MODALITY_TYPE}
393 * @exception java.lang.IllegalArgumentException if the {@code owner}'s
394 * {@code GraphicsConfiguration} is not from a screen device
395 * @exception HeadlessException when
396 * {@code GraphicsEnvironment.isHeadless()} returns {@code true}
397 *
398 * @see java.awt.Dialog.ModalityType
399 * @see java.awt.Dialog.ModalityType#MODELESS
400 * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
401 * @see java.awt.Dialog#setModal
402 * @see java.awt.Dialog#setModalityType
403 * @see java.awt.GraphicsEnvironment#isHeadless
404 * @see Component#setSize
405 * @see Component#setVisible
406 */
407 public Dialog(Frame owner, String title, boolean modal) {
408 this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS);
409 }
410
411 /**
412 * Constructs an initially invisible {@code Dialog} with the specified owner
413 * {@code Frame}, title, modality, and {@code GraphicsConfiguration}.
414 * @param owner the owner of the dialog or {@code null} if this dialog
415 * has no owner
416 * @param title the title of the dialog or {@code null} if this dialog
417 * has no title
418 * @param modal specifies whether dialog blocks user input to other top-level
419 * windows when shown. If {@code false}, the dialog is {@code MODELESS};
420 * if {@code true}, the modality type property is set to
421 * {@code DEFAULT_MODALITY_TYPE}
422 * @param gc the {@code GraphicsConfiguration} of the target screen device;
423 * if {@code null}, the default system {@code GraphicsConfiguration}
424 * is assumed
425 * @exception java.lang.IllegalArgumentException if {@code gc}
426 * is not from a screen device
427 * @exception HeadlessException when
428 * {@code GraphicsEnvironment.isHeadless()} returns {@code true}
429 *
430 * @see java.awt.Dialog.ModalityType
431 * @see java.awt.Dialog.ModalityType#MODELESS
432 * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
433 * @see java.awt.Dialog#setModal
434 * @see java.awt.Dialog#setModalityType
435 * @see java.awt.GraphicsEnvironment#isHeadless
436 * @see Component#setSize
437 * @see Component#setVisible
438 * @since 1.4
439 */
440 public Dialog(Frame owner, String title, boolean modal,
441 GraphicsConfiguration gc) {
442 this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS, gc);
443 }
444
445 /**
446 * Constructs an initially invisible, modeless {@code Dialog} with
447 * the specified owner {@code Dialog} and an empty title.
448 *
449 * @param owner the owner of the dialog or {@code null} if this
450 * dialog has no owner
451 * @exception java.lang.IllegalArgumentException if the {@code owner}'s
452 * {@code GraphicsConfiguration} is not from a screen device
453 * @exception HeadlessException when
454 * {@code GraphicsEnvironment.isHeadless()} returns {@code true}
455 * @see java.awt.GraphicsEnvironment#isHeadless
456 * @since 1.2
457 */
458 public Dialog(Dialog owner) {
459 this(owner, "", false);
460 }
461
462 /**
463 * Constructs an initially invisible, modeless {@code Dialog}
464 * with the specified owner {@code Dialog} and title.
465 *
466 * @param owner the owner of the dialog or {@code null} if this
467 * has no owner
468 * @param title the title of the dialog or {@code null} if this dialog
469 * has no title
470 * @exception java.lang.IllegalArgumentException if the {@code owner}'s
471 * {@code GraphicsConfiguration} is not from a screen device
472 * @exception HeadlessException when
473 * {@code GraphicsEnvironment.isHeadless()} returns {@code true}
474 *
475 * @see java.awt.GraphicsEnvironment#isHeadless
476 * @since 1.2
477 */
478 public Dialog(Dialog owner, String title) {
479 this(owner, title, false);
480 }
481
482 /**
483 * Constructs an initially invisible {@code Dialog} with the
484 * specified owner {@code Dialog}, title, and modality.
485 *
486 * @param owner the owner of the dialog or {@code null} if this
487 * dialog has no owner
488 * @param title the title of the dialog or {@code null} if this
489 * dialog has no title
490 * @param modal specifies whether dialog blocks user input to other top-level
491 * windows when shown. If {@code false}, the dialog is {@code MODELESS};
492 * if {@code true}, the modality type property is set to
493 * {@code DEFAULT_MODALITY_TYPE}
494 * @exception IllegalArgumentException if the {@code owner}'s
495 * {@code GraphicsConfiguration} is not from a screen device
496 * @exception HeadlessException when
497 * {@code GraphicsEnvironment.isHeadless()} returns {@code true}
498 *
499 * @see java.awt.Dialog.ModalityType
500 * @see java.awt.Dialog.ModalityType#MODELESS
501 * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
502 * @see java.awt.Dialog#setModal
503 * @see java.awt.Dialog#setModalityType
504 * @see java.awt.GraphicsEnvironment#isHeadless
505 *
506 * @since 1.2
507 */
508 public Dialog(Dialog owner, String title, boolean modal) {
509 this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS);
510 }
511
512 /**
513 * Constructs an initially invisible {@code Dialog} with the
514 * specified owner {@code Dialog}, title, modality and
515 * {@code GraphicsConfiguration}.
516 *
517 * @param owner the owner of the dialog or {@code null} if this
518 * dialog has no owner
519 * @param title the title of the dialog or {@code null} if this
520 * dialog has no title
521 * @param modal specifies whether dialog blocks user input to other top-level
522 * windows when shown. If {@code false}, the dialog is {@code MODELESS};
523 * if {@code true}, the modality type property is set to
524 * {@code DEFAULT_MODALITY_TYPE}
525 * @param gc the {@code GraphicsConfiguration} of the target screen device;
526 * if {@code null}, the default system {@code GraphicsConfiguration}
527 * is assumed
528 * @exception java.lang.IllegalArgumentException if {@code gc}
529 * is not from a screen device
530 * @exception HeadlessException when
531 * {@code GraphicsEnvironment.isHeadless()} returns {@code true}
532 *
533 * @see java.awt.Dialog.ModalityType
534 * @see java.awt.Dialog.ModalityType#MODELESS
535 * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
536 * @see java.awt.Dialog#setModal
537 * @see java.awt.Dialog#setModalityType
538 * @see java.awt.GraphicsEnvironment#isHeadless
539 * @see Component#setSize
540 * @see Component#setVisible
541 *
542 * @since 1.4
543 */
544 public Dialog(Dialog owner, String title, boolean modal,
545 GraphicsConfiguration gc) {
546 this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS, gc);
547 }
548
549 /**
550 * Constructs an initially invisible, modeless {@code Dialog} with the
551 * specified owner {@code Window} and an empty title.
552 *
553 * @param owner the owner of the dialog. The owner must be an instance of
554 * {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
555 * of their descendants or {@code null}
556 *
557 * @exception java.lang.IllegalArgumentException if the {@code owner}
558 * is not an instance of {@link java.awt.Dialog Dialog} or {@link
559 * java.awt.Frame Frame}
560 * @exception java.lang.IllegalArgumentException if the {@code owner}'s
561 * {@code GraphicsConfiguration} is not from a screen device
562 * @exception HeadlessException when
563 * {@code GraphicsEnvironment.isHeadless()} returns {@code true}
564 *
565 * @see java.awt.GraphicsEnvironment#isHeadless
566 *
567 * @since 1.6
568 */
569 public Dialog(Window owner) {
570 this(owner, "", ModalityType.MODELESS);
571 }
572
573 /**
574 * Constructs an initially invisible, modeless {@code Dialog} with
575 * the specified owner {@code Window} and title.
576 *
577 * @param owner the owner of the dialog. The owner must be an instance of
578 * {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
579 * of their descendants or {@code null}
580 * @param title the title of the dialog or {@code null} if this dialog
581 * has no title
582 *
583 * @exception java.lang.IllegalArgumentException if the {@code owner}
584 * is not an instance of {@link java.awt.Dialog Dialog} or {@link
585 * java.awt.Frame Frame}
586 * @exception java.lang.IllegalArgumentException if the {@code owner}'s
587 * {@code GraphicsConfiguration} is not from a screen device
588 * @exception HeadlessException when
589 * {@code GraphicsEnvironment.isHeadless()} returns {@code true}
590 *
591 * @see java.awt.GraphicsEnvironment#isHeadless
592 *
593 * @since 1.6
594 */
595 public Dialog(Window owner, String title) {
596 this(owner, title, ModalityType.MODELESS);
597 }
598
599 /**
600 * Constructs an initially invisible {@code Dialog} with the
601 * specified owner {@code Window} and modality and an empty title.
602 *
603 * @param owner the owner of the dialog. The owner must be an instance of
604 * {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
605 * of their descendants or {@code null}
606 * @param modalityType specifies whether dialog blocks input to other
607 * windows when shown. {@code null} value and unsupported modality
608 * types are equivalent to {@code MODELESS}
609 *
610 * @exception java.lang.IllegalArgumentException if the {@code owner}
611 * is not an instance of {@link java.awt.Dialog Dialog} or {@link
612 * java.awt.Frame Frame}
613 * @exception java.lang.IllegalArgumentException if the {@code owner}'s
614 * {@code GraphicsConfiguration} is not from a screen device
615 * @exception HeadlessException when
616 * {@code GraphicsEnvironment.isHeadless()} returns {@code true}
617 * @exception SecurityException if the calling thread does not have permission
618 * to create modal dialogs with the given {@code modalityType}
619 *
620 * @see java.awt.Dialog.ModalityType
621 * @see java.awt.Dialog#setModal
622 * @see java.awt.Dialog#setModalityType
623 * @see java.awt.GraphicsEnvironment#isHeadless
624 * @see java.awt.Toolkit#isModalityTypeSupported
625 *
626 * @since 1.6
627 */
628 public Dialog(Window owner, ModalityType modalityType) {
629 this(owner, "", modalityType);
630 }
631
632 /**
633 * Constructs an initially invisible {@code Dialog} with the
634 * specified owner {@code Window}, title and modality.
635 *
636 * @param owner the owner of the dialog. The owner must be an instance of
637 * {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
638 * of their descendants or {@code null}
639 * @param title the title of the dialog or {@code null} if this dialog
640 * has no title
641 * @param modalityType specifies whether dialog blocks input to other
642 * windows when shown. {@code null} value and unsupported modality
643 * types are equivalent to {@code MODELESS}
644 *
645 * @exception java.lang.IllegalArgumentException if the {@code owner}
646 * is not an instance of {@link java.awt.Dialog Dialog} or {@link
647 * java.awt.Frame Frame}
648 * @exception java.lang.IllegalArgumentException if the {@code owner}'s
649 * {@code GraphicsConfiguration} is not from a screen device
650 * @exception HeadlessException when
651 * {@code GraphicsEnvironment.isHeadless()} returns {@code true}
652 * @exception SecurityException if the calling thread does not have permission
653 * to create modal dialogs with the given {@code modalityType}
654 *
655 * @see java.awt.Dialog.ModalityType
656 * @see java.awt.Dialog#setModal
657 * @see java.awt.Dialog#setModalityType
658 * @see java.awt.GraphicsEnvironment#isHeadless
659 * @see java.awt.Toolkit#isModalityTypeSupported
660 *
661 * @since 1.6
662 */
663 public Dialog(Window owner, String title, ModalityType modalityType) {
664 super(owner);
665
666 if ((owner != null) &&
667 !(owner instanceof Frame) &&
668 !(owner instanceof Dialog))
669 {
670 throw new IllegalArgumentException("Wrong parent window");
671 }
672
673 this.title = title;
674 setModalityType(modalityType);
675 SunToolkit.checkAndSetPolicy(this);
676 initialized = true;
677 }
678
679 /**
680 * Constructs an initially invisible {@code Dialog} with the
681 * specified owner {@code Window}, title, modality and
682 * {@code GraphicsConfiguration}.
683 *
684 * @param owner the owner of the dialog. The owner must be an instance of
685 * {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
686 * of their descendants or {@code null}
687 * @param title the title of the dialog or {@code null} if this dialog
688 * has no title
689 * @param modalityType specifies whether dialog blocks input to other
690 * windows when shown. {@code null} value and unsupported modality
691 * types are equivalent to {@code MODELESS}
692 * @param gc the {@code GraphicsConfiguration} of the target screen device;
693 * if {@code null}, the default system {@code GraphicsConfiguration}
694 * is assumed
695 *
696 * @exception java.lang.IllegalArgumentException if the {@code owner}
697 * is not an instance of {@link java.awt.Dialog Dialog} or {@link
698 * java.awt.Frame Frame}
699 * @exception java.lang.IllegalArgumentException if {@code gc}
700 * is not from a screen device
701 * @exception HeadlessException when
702 * {@code GraphicsEnvironment.isHeadless()} returns {@code true}
703 * @exception SecurityException if the calling thread does not have permission
704 * to create modal dialogs with the given {@code modalityType}
705 *
706 * @see java.awt.Dialog.ModalityType
707 * @see java.awt.Dialog#setModal
708 * @see java.awt.Dialog#setModalityType
709 * @see java.awt.GraphicsEnvironment#isHeadless
710 * @see java.awt.Toolkit#isModalityTypeSupported
711 *
712 * @since 1.6
713 */
714 public Dialog(Window owner, String title, ModalityType modalityType,
715 GraphicsConfiguration gc) {
716 super(owner, gc);
717
718 if ((owner != null) &&
719 !(owner instanceof Frame) &&
720 !(owner instanceof Dialog))
721 {
722 throw new IllegalArgumentException("wrong owner window");
723 }
724
749 */
750 public void addNotify() {
751 synchronized (getTreeLock()) {
752 if (parent != null && parent.peer == null) {
753 parent.addNotify();
754 }
755
756 if (peer == null) {
757 peer = getComponentFactory().createDialog(this);
758 }
759 super.addNotify();
760 }
761 }
762
763 /**
764 * Indicates whether the dialog is modal.
765 * <p>
766 * This method is obsolete and is kept for backwards compatibility only.
767 * Use {@link #getModalityType getModalityType()} instead.
768 *
769 * @return {@code true} if this dialog window is modal;
770 * {@code false} otherwise
771 *
772 * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
773 * @see java.awt.Dialog.ModalityType#MODELESS
774 * @see java.awt.Dialog#setModal
775 * @see java.awt.Dialog#getModalityType
776 * @see java.awt.Dialog#setModalityType
777 */
778 public boolean isModal() {
779 return isModal_NoClientCode();
780 }
781 final boolean isModal_NoClientCode() {
782 return modalityType != ModalityType.MODELESS;
783 }
784
785 /**
786 * Specifies whether this dialog should be modal.
787 * <p>
788 * This method is obsolete and is kept for backwards compatibility only.
789 * Use {@link #setModalityType setModalityType()} instead.
790 * <p>
791 * Note: changing modality of the visible dialog may have no effect
792 * until it is hidden and then shown again.
793 *
794 * @param modal specifies whether dialog blocks input to other windows
795 * when shown; calling to {@code setModal(true)} is equivalent to
796 * {@code setModalityType(Dialog.DEFAULT_MODALITY_TYPE)}, and
797 * calling to {@code setModal(false)} is equivalent to
798 * {@code setModalityType(Dialog.ModalityType.MODELESS)}
799 *
800 * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
801 * @see java.awt.Dialog.ModalityType#MODELESS
802 * @see java.awt.Dialog#isModal
803 * @see java.awt.Dialog#getModalityType
804 * @see java.awt.Dialog#setModalityType
805 *
806 * @since 1.1
807 */
808 public void setModal(boolean modal) {
809 this.modal = modal;
810 setModalityType(modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS);
811 }
812
813 /**
814 * Returns the modality type of this dialog.
815 *
816 * @return modality type of this dialog
817 *
818 * @see java.awt.Dialog#setModalityType
819 *
820 * @since 1.6
821 */
822 public ModalityType getModalityType() {
823 return modalityType;
824 }
825
826 /**
827 * Sets the modality type for this dialog. See {@link
828 * java.awt.Dialog.ModalityType ModalityType} for possible modality types.
829 * <p>
830 * If the given modality type is not supported, {@code MODELESS}
831 * is used. You may want to call {@code getModalityType()} after calling
832 * this method to ensure that the modality type has been set.
833 * <p>
834 * Note: changing modality of the visible dialog may have no effect
835 * until it is hidden and then shown again.
836 *
837 * @param type specifies whether dialog blocks input to other
838 * windows when shown. {@code null} value and unsupported modality
839 * types are equivalent to {@code MODELESS}
840 * @exception SecurityException if the calling thread does not have permission
841 * to create modal dialogs with the given {@code modalityType}
842 *
843 * @see java.awt.Dialog#getModalityType
844 * @see java.awt.Toolkit#isModalityTypeSupported
845 *
846 * @since 1.6
847 */
848 public void setModalityType(ModalityType type) {
849 if (type == null) {
850 type = Dialog.ModalityType.MODELESS;
851 }
852 if (!Toolkit.getDefaultToolkit().isModalityTypeSupported(type)) {
853 type = Dialog.ModalityType.MODELESS;
854 }
855 if (modalityType == type) {
856 return;
857 }
858
859 checkModalityPermission(type);
860
861 modalityType = type;
862 modal = (modalityType != ModalityType.MODELESS);
863 }
864
865 /**
866 * Gets the title of the dialog. The title is displayed in the
867 * dialog's border.
868 * @return the title of this dialog window. The title may be
869 * {@code null}.
870 * @see java.awt.Dialog#setTitle
871 */
872 public String getTitle() {
873 return title;
874 }
875
876 /**
877 * Sets the title of the Dialog.
878 * @param title the title displayed in the dialog's border;
879 * a null value results in an empty title
880 * @see #getTitle
881 */
882 public void setTitle(String title) {
883 String oldTitle = this.title;
884
885 synchronized(this) {
886 this.title = title;
887 DialogPeer peer = (DialogPeer)this.peer;
888 if (peer != null) {
889 peer.setTitle(title);
1176 * <p>
1177 * If this dialog is modal and blocks some windows, then all of them are
1178 * also sent to the back to keep them below the blocking dialog.
1179 *
1180 * @see java.awt.Window#toBack
1181 */
1182 public void toBack() {
1183 super.toBack();
1184 if (visible) {
1185 synchronized (getTreeLock()) {
1186 for (Window w : blockedWindows) {
1187 w.toBack_NoClientCode();
1188 }
1189 }
1190 }
1191 }
1192
1193 /**
1194 * Indicates whether this dialog is resizable by the user.
1195 * By default, all dialogs are initially resizable.
1196 * @return {@code true} if the user can resize the dialog;
1197 * {@code false} otherwise.
1198 * @see java.awt.Dialog#setResizable
1199 */
1200 public boolean isResizable() {
1201 return resizable;
1202 }
1203
1204 /**
1205 * Sets whether this dialog is resizable by the user.
1206 * @param resizable {@code true} if the user can
1207 * resize this dialog; {@code false} otherwise.
1208 * @see java.awt.Dialog#isResizable
1209 */
1210 public void setResizable(boolean resizable) {
1211 boolean testvalid = false;
1212
1213 synchronized (this) {
1214 this.resizable = resizable;
1215 DialogPeer peer = (DialogPeer)this.peer;
1216 if (peer != null) {
1217 peer.setResizable(resizable);
1218 testvalid = true;
1219 }
1220 }
1221
1222 // On some platforms, changing the resizable state affects
1223 // the insets of the Dialog. If we could, we'd call invalidate()
1224 // from the peer, but we need to guarantee that we're not holding
1225 // the Dialog lock when we call invalidate().
1226 if (testvalid) {
1227 invalidateIfValid();
1266 }
1267 if (!undecorated) {
1268 if (getOpacity() < 1.0f) {
1269 throw new IllegalComponentStateException("The dialog is not opaque");
1270 }
1271 if (getShape() != null) {
1272 throw new IllegalComponentStateException("The dialog does not have a default shape");
1273 }
1274 Color bg = getBackground();
1275 if ((bg != null) && (bg.getAlpha() < 255)) {
1276 throw new IllegalComponentStateException("The dialog background color is not opaque");
1277 }
1278 }
1279 this.undecorated = undecorated;
1280 }
1281 }
1282
1283 /**
1284 * Indicates whether this dialog is undecorated.
1285 * By default, all dialogs are initially decorated.
1286 * @return {@code true} if dialog is undecorated;
1287 * {@code false} otherwise.
1288 * @see java.awt.Dialog#setUndecorated
1289 * @since 1.4
1290 */
1291 public boolean isUndecorated() {
1292 return undecorated;
1293 }
1294
1295 /**
1296 * {@inheritDoc}
1297 */
1298 @Override
1299 public void setOpacity(float opacity) {
1300 synchronized (getTreeLock()) {
1301 if ((opacity < 1.0f) && !isUndecorated()) {
1302 throw new IllegalComponentStateException("The dialog is decorated");
1303 }
1304 super.setOpacity(opacity);
1305 }
1306 }
1307
1319 }
1320
1321 /**
1322 * {@inheritDoc}
1323 */
1324 @Override
1325 public void setBackground(Color bgColor) {
1326 synchronized (getTreeLock()) {
1327 if ((bgColor != null) && (bgColor.getAlpha() < 255) && !isUndecorated()) {
1328 throw new IllegalComponentStateException("The dialog is decorated");
1329 }
1330 super.setBackground(bgColor);
1331 }
1332 }
1333
1334 /**
1335 * Returns a string representing the state of this dialog. This
1336 * method is intended to be used only for debugging purposes, and the
1337 * content and format of the returned string may vary between
1338 * implementations. The returned string may be empty but may not be
1339 * {@code null}.
1340 *
1341 * @return the parameter string of this dialog window.
1342 */
1343 protected String paramString() {
1344 String str = super.paramString() + "," + modalityType;
1345 if (title != null) {
1346 str += ",title=" + title;
1347 }
1348 return str;
1349 }
1350
1351 /**
1352 * Initialize JNI field and method IDs
1353 */
1354 private static native void initIDs();
1355
1356 /*
1357 * --- Modality support ---
1358 *
1359 */
1630
1631 /**
1632 * Gets the AccessibleContext associated with this Dialog.
1633 * For dialogs, the AccessibleContext takes the form of an
1634 * AccessibleAWTDialog.
1635 * A new AccessibleAWTDialog instance is created if necessary.
1636 *
1637 * @return an AccessibleAWTDialog that serves as the
1638 * AccessibleContext of this Dialog
1639 * @since 1.3
1640 */
1641 public AccessibleContext getAccessibleContext() {
1642 if (accessibleContext == null) {
1643 accessibleContext = new AccessibleAWTDialog();
1644 }
1645 return accessibleContext;
1646 }
1647
1648 /**
1649 * This class implements accessibility support for the
1650 * {@code Dialog} class. It provides an implementation of the
1651 * Java Accessibility API appropriate to dialog user-interface elements.
1652 * @since 1.3
1653 */
1654 protected class AccessibleAWTDialog extends AccessibleAWTWindow
1655 {
1656 /*
1657 * JDK 1.3 serialVersionUID
1658 */
1659 private static final long serialVersionUID = 4837230331833941201L;
1660
1661 /**
1662 * Get the role of this object.
1663 *
1664 * @return an instance of AccessibleRole describing the role of the
1665 * object
1666 * @see AccessibleRole
1667 */
1668 public AccessibleRole getAccessibleRole() {
1669 return AccessibleRole.DIALOG;
1670 }
|