author | malenkov |
Mon, 14 Oct 2013 13:22:36 +0400 | |
changeset 21255 | 0afb44cd0215 |
parent 20458 | f2423fb3fd19 |
child 21278 | ef8a3a2a72f2 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
package javax.swing; |
|
26 |
||
27 |
import java.awt.*; |
|
28 |
import java.awt.event.*; |
|
29 |
import javax.accessibility.*; |
|
30 |
||
31 |
/** |
|
32 |
* The main class for creating a dialog window. You can use this class |
|
33 |
* to create a custom dialog, or invoke the many class methods |
|
34 |
* in {@link JOptionPane} to create a variety of standard dialogs. |
|
35 |
* For information about creating dialogs, see |
|
36 |
* <em>The Java Tutorial</em> section |
|
37 |
* <a |
|
20455
f6f9a0c2796b
8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents:
12661
diff
changeset
|
38 |
href="http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html">How |
2 | 39 |
* to Make Dialogs</a>. |
40 |
* |
|
41 |
* <p> |
|
42 |
* |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
43 |
* The {@code JDialog} component contains a {@code JRootPane} |
2 | 44 |
* as its only child. |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
45 |
* The {@code contentPane} should be the parent of any children of the |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
46 |
* {@code JDialog}. |
21255
0afb44cd0215
7165112: Incomprehensible garbage in doc for RootPaneContainer
malenkov
parents:
20458
diff
changeset
|
47 |
* As a convenience, the {@code add}, {@code remove}, and {@code setLayout} |
0afb44cd0215
7165112: Incomprehensible garbage in doc for RootPaneContainer
malenkov
parents:
20458
diff
changeset
|
48 |
* methods of this class are overridden, so that they delegate calls |
0afb44cd0215
7165112: Incomprehensible garbage in doc for RootPaneContainer
malenkov
parents:
20458
diff
changeset
|
49 |
* to the corresponding methods of the {@code ContentPane}. |
0afb44cd0215
7165112: Incomprehensible garbage in doc for RootPaneContainer
malenkov
parents:
20458
diff
changeset
|
50 |
* For example, you can add a child component to a dialog as follows: |
2 | 51 |
* <pre> |
52 |
* dialog.add(child); |
|
53 |
* </pre> |
|
54 |
* And the child will be added to the contentPane. |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
55 |
* The {@code contentPane} is always non-{@code null}. |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
56 |
* Attempting to set it to {@code null} generates an exception. |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
57 |
* The default {@code contentPane} has a {@code BorderLayout} |
2 | 58 |
* manager set on it. |
59 |
* Refer to {@link javax.swing.RootPaneContainer} |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
60 |
* for details on adding, removing and setting the {@code LayoutManager} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
61 |
* of a {@code JDialog}. |
2 | 62 |
* <p> |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
63 |
* Please see the {@code JRootPane} documentation for a complete |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
64 |
* description of the {@code contentPane}, {@code glassPane}, |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
65 |
* and {@code layeredPane} components. |
2 | 66 |
* <p> |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
67 |
* In a multi-screen environment, you can create a {@code JDialog} |
2 | 68 |
* on a different screen device than its owner. See {@link java.awt.Frame} for |
69 |
* more information. |
|
70 |
* <p> |
|
71 |
* <strong>Warning:</strong> Swing is not thread safe. For more |
|
72 |
* information see <a |
|
73 |
* href="package-summary.html#threading">Swing's Threading |
|
74 |
* Policy</a>. |
|
75 |
* <p> |
|
76 |
* <strong>Warning:</strong> |
|
77 |
* Serialized objects of this class will not be compatible with |
|
78 |
* future Swing releases. The current serialization support is |
|
79 |
* appropriate for short term storage or RMI between applications running |
|
80 |
* the same version of Swing. As of 1.4, support for long term storage |
|
20458 | 81 |
* of all JavaBeans™ |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
82 |
* has been added to the {@code java.beans} package. |
2 | 83 |
* Please see {@link java.beans.XMLEncoder}. |
84 |
* |
|
85 |
* @see JOptionPane |
|
86 |
* @see JRootPane |
|
87 |
* @see javax.swing.RootPaneContainer |
|
88 |
* |
|
89 |
* @beaninfo |
|
90 |
* attribute: isContainer true |
|
91 |
* attribute: containerDelegate getContentPane |
|
92 |
* description: A toplevel window for creating dialog boxes. |
|
93 |
* |
|
94 |
* @author David Kloba |
|
95 |
* @author James Gosling |
|
96 |
* @author Scott Violet |
|
97 |
*/ |
|
98 |
public class JDialog extends Dialog implements WindowConstants, |
|
99 |
Accessible, |
|
100 |
RootPaneContainer, |
|
101 |
TransferHandler.HasGetTransferHandler |
|
102 |
{ |
|
103 |
/** |
|
104 |
* Key into the AppContext, used to check if should provide decorations |
|
105 |
* by default. |
|
106 |
*/ |
|
107 |
private static final Object defaultLookAndFeelDecoratedKey = |
|
108 |
new StringBuffer("JDialog.defaultLookAndFeelDecorated"); |
|
109 |
||
110 |
private int defaultCloseOperation = HIDE_ON_CLOSE; |
|
111 |
||
112 |
/** |
|
113 |
* @see #getRootPane |
|
114 |
* @see #setRootPane |
|
115 |
*/ |
|
116 |
protected JRootPane rootPane; |
|
117 |
||
118 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
119 |
* If true then calls to {@code add} and {@code setLayout} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
120 |
* will be forwarded to the {@code contentPane}. This is initially |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
121 |
* false, but is set to true when the {@code JDialog} is constructed. |
2 | 122 |
* |
123 |
* @see #isRootPaneCheckingEnabled |
|
124 |
* @see #setRootPaneCheckingEnabled |
|
125 |
* @see javax.swing.RootPaneContainer |
|
126 |
*/ |
|
127 |
protected boolean rootPaneCheckingEnabled = false; |
|
128 |
||
129 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
130 |
* The {@code TransferHandler} for this dialog. |
2 | 131 |
*/ |
132 |
private TransferHandler transferHandler; |
|
133 |
||
134 |
/** |
|
135 |
* Creates a modeless dialog without a title and without a specified |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
136 |
* {@code Frame} owner. A shared, hidden frame will be |
2 | 137 |
* set as the owner of the dialog. |
138 |
* <p> |
|
139 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
140 |
* returned by {@code JComponent.getDefaultLocale}. |
2 | 141 |
* <p> |
142 |
* NOTE: This constructor does not allow you to create an unowned |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
143 |
* {@code JDialog}. To create an unowned {@code JDialog} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
144 |
* you must use either the {@code JDialog(Window)} or |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
145 |
* {@code JDialog(Dialog)} constructor with an argument of |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
146 |
* {@code null}. |
2 | 147 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
148 |
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
149 |
* returns {@code true}. |
2 | 150 |
* @see java.awt.GraphicsEnvironment#isHeadless |
151 |
* @see JComponent#getDefaultLocale |
|
152 |
*/ |
|
153 |
public JDialog() { |
|
154 |
this((Frame)null, false); |
|
155 |
} |
|
156 |
||
157 |
/** |
|
7500
dec4b445efc6
6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents:
7012
diff
changeset
|
158 |
* Creates a modeless dialog with the specified {@code Frame} |
dec4b445efc6
6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents:
7012
diff
changeset
|
159 |
* as its owner and an empty title. If {@code owner} |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
160 |
* is {@code null}, a shared, hidden frame will be set as the |
2 | 161 |
* owner of the dialog. |
162 |
* <p> |
|
163 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
164 |
* returned by {@code JComponent.getDefaultLocale}. |
2 | 165 |
* <p> |
166 |
* NOTE: This constructor does not allow you to create an unowned |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
167 |
* {@code JDialog}. To create an unowned {@code JDialog} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
168 |
* you must use either the {@code JDialog(Window)} or |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
169 |
* {@code JDialog(Dialog)} constructor with an argument of |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
170 |
* {@code null}. |
2 | 171 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
172 |
* @param owner the {@code Frame} from which the dialog is displayed |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
173 |
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
174 |
* returns {@code true}. |
2 | 175 |
* @see java.awt.GraphicsEnvironment#isHeadless |
176 |
* @see JComponent#getDefaultLocale |
|
177 |
*/ |
|
178 |
public JDialog(Frame owner) { |
|
179 |
this(owner, false); |
|
180 |
} |
|
181 |
||
182 |
/** |
|
7500
dec4b445efc6
6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents:
7012
diff
changeset
|
183 |
* Creates a dialog with an empty title and the specified modality and |
dec4b445efc6
6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents:
7012
diff
changeset
|
184 |
* {@code Frame} as its owner. If {@code owner} is {@code null}, |
2 | 185 |
* a shared, hidden frame will be set as the owner of the dialog. |
186 |
* <p> |
|
187 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
188 |
* returned by {@code JComponent.getDefaultLocale}. |
2 | 189 |
* <p> |
190 |
* NOTE: This constructor does not allow you to create an unowned |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
191 |
* {@code JDialog}. To create an unowned {@code JDialog} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
192 |
* you must use either the {@code JDialog(Window)} or |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
193 |
* {@code JDialog(Dialog)} constructor with an argument of |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
194 |
* {@code null}. |
2 | 195 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
196 |
* @param owner the {@code Frame} from which the dialog is displayed |
2 | 197 |
* @param modal specifies whether dialog blocks user input to other top-level |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
198 |
* windows when shown. If {@code true}, the modality type property is set to |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
199 |
* {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless. |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
200 |
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
201 |
* returns {@code true}. |
2 | 202 |
* @see java.awt.GraphicsEnvironment#isHeadless |
203 |
* @see JComponent#getDefaultLocale |
|
204 |
*/ |
|
205 |
public JDialog(Frame owner, boolean modal) { |
|
7500
dec4b445efc6
6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents:
7012
diff
changeset
|
206 |
this(owner, "", modal); |
2 | 207 |
} |
208 |
||
209 |
/** |
|
210 |
* Creates a modeless dialog with the specified title and |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
211 |
* with the specified owner frame. If {@code owner} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
212 |
* is {@code null}, a shared, hidden frame will be set as the |
2 | 213 |
* owner of the dialog. |
214 |
* <p> |
|
215 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
216 |
* returned by {@code JComponent.getDefaultLocale}. |
2 | 217 |
* <p> |
218 |
* NOTE: This constructor does not allow you to create an unowned |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
219 |
* {@code JDialog}. To create an unowned {@code JDialog} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
220 |
* you must use either the {@code JDialog(Window)} or |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
221 |
* {@code JDialog(Dialog)} constructor with an argument of |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
222 |
* {@code null}. |
2 | 223 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
224 |
* @param owner the {@code Frame} from which the dialog is displayed |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
225 |
* @param title the {@code String} to display in the dialog's |
2 | 226 |
* title bar |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
227 |
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
228 |
* returns {@code true}. |
2 | 229 |
* @see java.awt.GraphicsEnvironment#isHeadless |
230 |
* @see JComponent#getDefaultLocale |
|
231 |
*/ |
|
232 |
public JDialog(Frame owner, String title) { |
|
233 |
this(owner, title, false); |
|
234 |
} |
|
235 |
||
236 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
237 |
* Creates a dialog with the specified title, owner {@code Frame} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
238 |
* and modality. If {@code owner} is {@code null}, |
2 | 239 |
* a shared, hidden frame will be set as the owner of this dialog. |
240 |
* <p> |
|
241 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
242 |
* returned by {@code JComponent.getDefaultLocale}. |
2 | 243 |
* <p> |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
244 |
* NOTE: Any popup components ({@code JComboBox}, |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
245 |
* {@code JPopupMenu}, {@code JMenuBar}) |
2 | 246 |
* created within a modal dialog will be forced to be lightweight. |
247 |
* <p> |
|
248 |
* NOTE: This constructor does not allow you to create an unowned |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
249 |
* {@code JDialog}. To create an unowned {@code JDialog} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
250 |
* you must use either the {@code JDialog(Window)} or |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
251 |
* {@code JDialog(Dialog)} constructor with an argument of |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
252 |
* {@code null}. |
2 | 253 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
254 |
* @param owner the {@code Frame} from which the dialog is displayed |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
255 |
* @param title the {@code String} to display in the dialog's |
2 | 256 |
* title bar |
257 |
* @param modal specifies whether dialog blocks user input to other top-level |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
258 |
* windows when shown. If {@code true}, the modality type property is set to |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
259 |
* {@code DEFAULT_MODALITY_TYPE} otherwise the dialog is modeless |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
260 |
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
261 |
* returns {@code true}. |
2 | 262 |
* |
263 |
* @see java.awt.Dialog.ModalityType |
|
264 |
* @see java.awt.Dialog.ModalityType#MODELESS |
|
265 |
* @see java.awt.Dialog#DEFAULT_MODALITY_TYPE |
|
266 |
* @see java.awt.Dialog#setModal |
|
267 |
* @see java.awt.Dialog#setModalityType |
|
268 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
269 |
* @see JComponent#getDefaultLocale |
|
270 |
*/ |
|
271 |
public JDialog(Frame owner, String title, boolean modal) { |
|
272 |
super(owner == null? SwingUtilities.getSharedOwnerFrame() : owner, |
|
273 |
title, modal); |
|
274 |
if (owner == null) { |
|
275 |
WindowListener ownerShutdownListener = |
|
1301
15e81207e1f2
6727662: Code improvement and warnings removing from swing packages
rupashka
parents:
2
diff
changeset
|
276 |
SwingUtilities.getSharedOwnerFrameShutdownListener(); |
2 | 277 |
addWindowListener(ownerShutdownListener); |
278 |
} |
|
279 |
dialogInit(); |
|
280 |
} |
|
281 |
||
282 |
/** |
|
283 |
* Creates a dialog with the specified title, |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
284 |
* owner {@code Frame}, modality and {@code GraphicsConfiguration}. |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
285 |
* If {@code owner} is {@code null}, |
2 | 286 |
* a shared, hidden frame will be set as the owner of this dialog. |
287 |
* <p> |
|
288 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
289 |
* returned by {@code JComponent.getDefaultLocale}. |
2 | 290 |
* <p> |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
291 |
* NOTE: Any popup components ({@code JComboBox}, |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
292 |
* {@code JPopupMenu}, {@code JMenuBar}) |
2 | 293 |
* created within a modal dialog will be forced to be lightweight. |
294 |
* <p> |
|
295 |
* NOTE: This constructor does not allow you to create an unowned |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
296 |
* {@code JDialog}. To create an unowned {@code JDialog} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
297 |
* you must use either the {@code JDialog(Window)} or |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
298 |
* {@code JDialog(Dialog)} constructor with an argument of |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
299 |
* {@code null}. |
2 | 300 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
301 |
* @param owner the {@code Frame} from which the dialog is displayed |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
302 |
* @param title the {@code String} to display in the dialog's |
2 | 303 |
* title bar |
304 |
* @param modal specifies whether dialog blocks user input to other top-level |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
305 |
* windows when shown. If {@code true}, the modality type property is set to |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
306 |
* {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless. |
7012
a1b12adbb080
6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents:
6511
diff
changeset
|
307 |
* @param gc the {@code GraphicsConfiguration} of the target screen device; |
a1b12adbb080
6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents:
6511
diff
changeset
|
308 |
* if {@code null}, the default system {@code GraphicsConfiguration} |
a1b12adbb080
6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents:
6511
diff
changeset
|
309 |
* is assumed |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
310 |
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
311 |
* returns {@code true}. |
2 | 312 |
* @see java.awt.Dialog.ModalityType |
313 |
* @see java.awt.Dialog.ModalityType#MODELESS |
|
314 |
* @see java.awt.Dialog#DEFAULT_MODALITY_TYPE |
|
315 |
* @see java.awt.Dialog#setModal |
|
316 |
* @see java.awt.Dialog#setModalityType |
|
317 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
318 |
* @see JComponent#getDefaultLocale |
|
319 |
* @since 1.4 |
|
320 |
*/ |
|
321 |
public JDialog(Frame owner, String title, boolean modal, |
|
322 |
GraphicsConfiguration gc) { |
|
323 |
super(owner == null? SwingUtilities.getSharedOwnerFrame() : owner, |
|
324 |
title, modal, gc); |
|
325 |
if (owner == null) { |
|
326 |
WindowListener ownerShutdownListener = |
|
1301
15e81207e1f2
6727662: Code improvement and warnings removing from swing packages
rupashka
parents:
2
diff
changeset
|
327 |
SwingUtilities.getSharedOwnerFrameShutdownListener(); |
2 | 328 |
addWindowListener(ownerShutdownListener); |
329 |
} |
|
330 |
dialogInit(); |
|
331 |
} |
|
332 |
||
333 |
/** |
|
7500
dec4b445efc6
6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents:
7012
diff
changeset
|
334 |
* Creates a modeless dialog with the specified {@code Dialog} |
dec4b445efc6
6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents:
7012
diff
changeset
|
335 |
* as its owner and an empty title. |
2 | 336 |
* <p> |
337 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
338 |
* returned by {@code JComponent.getDefaultLocale}. |
2 | 339 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
340 |
* @param owner the owner {@code Dialog} from which the dialog is displayed |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
341 |
* or {@code null} if this dialog has no owner |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
342 |
* @throws HeadlessException {@code if GraphicsEnvironment.isHeadless()} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
343 |
* returns {@code true}. |
2 | 344 |
* @see java.awt.GraphicsEnvironment#isHeadless |
345 |
* @see JComponent#getDefaultLocale |
|
346 |
*/ |
|
347 |
public JDialog(Dialog owner) { |
|
348 |
this(owner, false); |
|
349 |
} |
|
350 |
||
351 |
/** |
|
7500
dec4b445efc6
6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents:
7012
diff
changeset
|
352 |
* Creates a dialog with an empty title and the specified modality and |
dec4b445efc6
6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents:
7012
diff
changeset
|
353 |
* {@code Dialog} as its owner. |
2 | 354 |
* <p> |
355 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
356 |
* returned by {@code JComponent.getDefaultLocale}. |
2 | 357 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
358 |
* @param owner the owner {@code Dialog} from which the dialog is displayed |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
359 |
* or {@code null} if this dialog has no owner |
2 | 360 |
* @param modal specifies whether dialog blocks user input to other top-level |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
361 |
* windows when shown. If {@code true}, the modality type property is set to |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
362 |
* {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless. |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
363 |
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
364 |
* returns {@code true}. |
2 | 365 |
* @see java.awt.Dialog.ModalityType |
366 |
* @see java.awt.Dialog.ModalityType#MODELESS |
|
367 |
* @see java.awt.Dialog#DEFAULT_MODALITY_TYPE |
|
368 |
* @see java.awt.Dialog#setModal |
|
369 |
* @see java.awt.Dialog#setModalityType |
|
370 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
371 |
* @see JComponent#getDefaultLocale |
|
372 |
*/ |
|
373 |
public JDialog(Dialog owner, boolean modal) { |
|
7500
dec4b445efc6
6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents:
7012
diff
changeset
|
374 |
this(owner, "", modal); |
2 | 375 |
} |
376 |
||
377 |
/** |
|
378 |
* Creates a modeless dialog with the specified title and |
|
379 |
* with the specified owner dialog. |
|
380 |
* <p> |
|
381 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
382 |
* returned by {@code JComponent.getDefaultLocale}. |
2 | 383 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
384 |
* @param owner the owner {@code Dialog} from which the dialog is displayed |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
385 |
* or {@code null} if this dialog has no owner |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
386 |
* @param title the {@code String} to display in the dialog's |
2 | 387 |
* title bar |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
388 |
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
389 |
* returns {@code true}. |
2 | 390 |
* @see java.awt.GraphicsEnvironment#isHeadless |
391 |
* @see JComponent#getDefaultLocale |
|
392 |
*/ |
|
393 |
public JDialog(Dialog owner, String title) { |
|
394 |
this(owner, title, false); |
|
395 |
} |
|
396 |
||
397 |
/** |
|
398 |
* Creates a dialog with the specified title, modality |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
399 |
* and the specified owner {@code Dialog}. |
2 | 400 |
* <p> |
401 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
402 |
* returned by {@code JComponent.getDefaultLocale}. |
2 | 403 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
404 |
* @param owner the owner {@code Dialog} from which the dialog is displayed |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
405 |
* or {@code null} if this dialog has no owner |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
406 |
* @param title the {@code String} to display in the dialog's |
2 | 407 |
* title bar |
408 |
* @param modal specifies whether dialog blocks user input to other top-level |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
409 |
* windows when shown. If {@code true}, the modality type property is set to |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
410 |
* {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
411 |
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
412 |
* returns {@code true}. |
2 | 413 |
* @see java.awt.Dialog.ModalityType |
414 |
* @see java.awt.Dialog.ModalityType#MODELESS |
|
415 |
* @see java.awt.Dialog#DEFAULT_MODALITY_TYPE |
|
416 |
* @see java.awt.Dialog#setModal |
|
417 |
* @see java.awt.Dialog#setModalityType |
|
418 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
419 |
* @see JComponent#getDefaultLocale |
|
420 |
*/ |
|
421 |
public JDialog(Dialog owner, String title, boolean modal) { |
|
422 |
super(owner, title, modal); |
|
423 |
dialogInit(); |
|
424 |
} |
|
425 |
||
426 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
427 |
* Creates a dialog with the specified title, owner {@code Dialog}, |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
428 |
* modality and {@code GraphicsConfiguration}. |
2 | 429 |
* |
430 |
* <p> |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
431 |
* NOTE: Any popup components ({@code JComboBox}, |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
432 |
* {@code JPopupMenu}, {@code JMenuBar}) |
2 | 433 |
* created within a modal dialog will be forced to be lightweight. |
434 |
* <p> |
|
435 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
436 |
* returned by {@code JComponent.getDefaultLocale}. |
2 | 437 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
438 |
* @param owner the owner {@code Dialog} from which the dialog is displayed |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
439 |
* or {@code null} if this dialog has no owner |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
440 |
* @param title the {@code String} to display in the dialog's |
2 | 441 |
* title bar |
442 |
* @param modal specifies whether dialog blocks user input to other top-level |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
443 |
* windows when shown. If {@code true}, the modality type property is set to |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
444 |
* {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless |
7012
a1b12adbb080
6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents:
6511
diff
changeset
|
445 |
* @param gc the {@code GraphicsConfiguration} of the target screen device; |
a1b12adbb080
6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents:
6511
diff
changeset
|
446 |
* if {@code null}, the default system {@code GraphicsConfiguration} |
a1b12adbb080
6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents:
6511
diff
changeset
|
447 |
* is assumed |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
448 |
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
449 |
* returns {@code true}. |
2 | 450 |
* @see java.awt.Dialog.ModalityType |
451 |
* @see java.awt.Dialog.ModalityType#MODELESS |
|
452 |
* @see java.awt.Dialog#DEFAULT_MODALITY_TYPE |
|
453 |
* @see java.awt.Dialog#setModal |
|
454 |
* @see java.awt.Dialog#setModalityType |
|
455 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
456 |
* @see JComponent#getDefaultLocale |
|
457 |
* @since 1.4 |
|
458 |
*/ |
|
459 |
public JDialog(Dialog owner, String title, boolean modal, |
|
460 |
GraphicsConfiguration gc) { |
|
461 |
super(owner, title, modal, gc); |
|
462 |
dialogInit(); |
|
463 |
} |
|
464 |
||
465 |
/** |
|
7500
dec4b445efc6
6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents:
7012
diff
changeset
|
466 |
* Creates a modeless dialog with the specified {@code Window} |
dec4b445efc6
6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents:
7012
diff
changeset
|
467 |
* as its owner and an empty title. |
2 | 468 |
* <p> |
469 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
470 |
* returned by {@code JComponent.getDefaultLocale}. |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
471 |
* |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
472 |
* @param owner the {@code Window} from which the dialog is displayed or |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
473 |
* {@code null} if this dialog has no owner |
2 | 474 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
475 |
* @throws IllegalArgumentException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
476 |
* if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
477 |
* or {@link java.awt.Frame Frame} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
478 |
* @throws IllegalArgumentException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
479 |
* if the {@code owner}'s {@code GraphicsConfiguration} is not from a screen device |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
480 |
* @throws HeadlessException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
481 |
* when {@code GraphicsEnvironment.isHeadless()} returns {@code true} |
2 | 482 |
* |
483 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
484 |
* @see JComponent#getDefaultLocale |
|
485 |
* |
|
486 |
* @since 1.6 |
|
487 |
*/ |
|
488 |
public JDialog(Window owner) { |
|
489 |
this(owner, Dialog.ModalityType.MODELESS); |
|
490 |
} |
|
491 |
||
492 |
/** |
|
7500
dec4b445efc6
6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents:
7012
diff
changeset
|
493 |
* Creates a dialog with an empty title and the specified modality and |
dec4b445efc6
6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents:
7012
diff
changeset
|
494 |
* {@code Window} as its owner. |
2 | 495 |
* <p> |
496 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
497 |
* returned by {@code JComponent.getDefaultLocale}. |
2 | 498 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
499 |
* @param owner the {@code Window} from which the dialog is displayed or |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
500 |
* {@code null} if this dialog has no owner |
2 | 501 |
* @param modalityType specifies whether dialog blocks input to other |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
502 |
* windows when shown. {@code null} value and unsupported modality |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
503 |
* types are equivalent to {@code MODELESS} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
504 |
* |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
505 |
* @throws IllegalArgumentException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
506 |
* if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
507 |
* or {@link java.awt.Frame Frame} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
508 |
* @throws IllegalArgumentException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
509 |
* if the {@code owner}'s {@code GraphicsConfiguration} is not from a screen device |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
510 |
* @throws HeadlessException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
511 |
* when {@code GraphicsEnvironment.isHeadless()} returns {@code true} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
512 |
* @throws SecurityException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
513 |
* if the calling thread does not have permission to create modal dialogs |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
514 |
* with the given {@code modalityType} |
2 | 515 |
* |
516 |
* @see java.awt.Dialog.ModalityType |
|
517 |
* @see java.awt.Dialog#setModal |
|
518 |
* @see java.awt.Dialog#setModalityType |
|
519 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
520 |
* @see JComponent#getDefaultLocale |
|
521 |
* |
|
522 |
* @since 1.6 |
|
523 |
*/ |
|
524 |
public JDialog(Window owner, ModalityType modalityType) { |
|
7500
dec4b445efc6
6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents:
7012
diff
changeset
|
525 |
this(owner, "", modalityType); |
2 | 526 |
} |
527 |
||
528 |
/** |
|
529 |
* Creates a modeless dialog with the specified title and owner |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
530 |
* {@code Window}. |
2 | 531 |
* <p> |
532 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
533 |
* returned by {@code JComponent.getDefaultLocale}. |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
534 |
* |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
535 |
* @param owner the {@code Window} from which the dialog is displayed or |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
536 |
* {@code null} if this dialog has no owner |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
537 |
* @param title the {@code String} to display in the dialog's |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
538 |
* title bar or {@code null} if the dialog has no title |
2 | 539 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
540 |
* @throws IllegalArgumentException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
541 |
* if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
542 |
* or {@link java.awt.Frame Frame} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
543 |
* @throws IllegalArgumentException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
544 |
* if the {@code owner}'s {@code GraphicsConfiguration} is not from a screen device |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
545 |
* @throws HeadlessException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
546 |
* when {@code GraphicsEnvironment.isHeadless()} returns {@code true} |
2 | 547 |
* |
548 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
549 |
* @see JComponent#getDefaultLocale |
|
550 |
* |
|
551 |
* @since 1.6 |
|
552 |
*/ |
|
553 |
public JDialog(Window owner, String title) { |
|
554 |
this(owner, title, Dialog.ModalityType.MODELESS); |
|
555 |
} |
|
556 |
||
557 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
558 |
* Creates a dialog with the specified title, owner {@code Window} and |
2 | 559 |
* modality. |
560 |
* <p> |
|
561 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
562 |
* returned by {@code JComponent.getDefaultLocale}. |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
563 |
* |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
564 |
* @param owner the {@code Window} from which the dialog is displayed or |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
565 |
* {@code null} if this dialog has no owner |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
566 |
* @param title the {@code String} to display in the dialog's |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
567 |
* title bar or {@code null} if the dialog has no title |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
568 |
* @param modalityType specifies whether dialog blocks input to other |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
569 |
* windows when shown. {@code null} value and unsupported modality |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
570 |
* types are equivalent to {@code MODELESS} |
2 | 571 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
572 |
* @throws IllegalArgumentException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
573 |
* if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
574 |
* or {@link java.awt.Frame Frame} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
575 |
* @throws IllegalArgumentException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
576 |
* if the {@code owner}'s {@code GraphicsConfiguration} is not from a screen device |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
577 |
* @throws HeadlessException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
578 |
* when {@code GraphicsEnvironment.isHeadless()} returns {@code true} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
579 |
* @throws SecurityException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
580 |
* if the calling thread does not have permission to create modal dialogs |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
581 |
* with the given {@code modalityType} |
2 | 582 |
* |
583 |
* @see java.awt.Dialog.ModalityType |
|
584 |
* @see java.awt.Dialog#setModal |
|
585 |
* @see java.awt.Dialog#setModalityType |
|
586 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
587 |
* @see JComponent#getDefaultLocale |
|
588 |
* |
|
589 |
* @since 1.6 |
|
590 |
*/ |
|
591 |
public JDialog(Window owner, String title, Dialog.ModalityType modalityType) { |
|
592 |
super(owner, title, modalityType); |
|
593 |
dialogInit(); |
|
594 |
} |
|
595 |
||
596 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
597 |
* Creates a dialog with the specified title, owner {@code Window}, |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
598 |
* modality and {@code GraphicsConfiguration}. |
2 | 599 |
* <p> |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
600 |
* NOTE: Any popup components ({@code JComboBox}, |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
601 |
* {@code JPopupMenu}, {@code JMenuBar}) |
2 | 602 |
* created within a modal dialog will be forced to be lightweight. |
603 |
* <p> |
|
604 |
* This constructor sets the component's locale property to the value |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
605 |
* returned by {@code JComponent.getDefaultLocale}. |
2 | 606 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
607 |
* @param owner the {@code Window} from which the dialog is displayed or |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
608 |
* {@code null} if this dialog has no owner |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
609 |
* @param title the {@code String} to display in the dialog's |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
610 |
* title bar or {@code null} if the dialog has no title |
2 | 611 |
* @param modalityType specifies whether dialog blocks input to other |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
612 |
* windows when shown. {@code null} value and unsupported modality |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
613 |
* types are equivalent to {@code MODELESS} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
614 |
* @param gc the {@code GraphicsConfiguration} of the target screen device; |
7012
a1b12adbb080
6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents:
6511
diff
changeset
|
615 |
* if {@code null}, the default system {@code GraphicsConfiguration} |
a1b12adbb080
6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents:
6511
diff
changeset
|
616 |
* is assumed |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
617 |
* @throws IllegalArgumentException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
618 |
* if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
619 |
* or {@link java.awt.Frame Frame} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
620 |
* @throws IllegalArgumentException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
621 |
* if the {@code owner}'s {@code GraphicsConfiguration} is not from a screen device |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
622 |
* @throws HeadlessException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
623 |
* when {@code GraphicsEnvironment.isHeadless()} returns {@code true} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
624 |
* @throws SecurityException |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
625 |
* if the calling thread does not have permission to create modal dialogs |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
626 |
* with the given {@code modalityType} |
2 | 627 |
* |
628 |
* @see java.awt.Dialog.ModalityType |
|
629 |
* @see java.awt.Dialog#setModal |
|
630 |
* @see java.awt.Dialog#setModalityType |
|
631 |
* @see java.awt.GraphicsEnvironment#isHeadless |
|
632 |
* @see JComponent#getDefaultLocale |
|
633 |
* |
|
634 |
* @since 1.6 |
|
635 |
*/ |
|
636 |
public JDialog(Window owner, String title, Dialog.ModalityType modalityType, |
|
637 |
GraphicsConfiguration gc) { |
|
638 |
super(owner, title, modalityType, gc); |
|
639 |
dialogInit(); |
|
640 |
} |
|
641 |
||
642 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
643 |
* Called by the constructors to init the {@code JDialog} properly. |
2 | 644 |
*/ |
645 |
protected void dialogInit() { |
|
646 |
enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK); |
|
647 |
setLocale( JComponent.getDefaultLocale() ); |
|
648 |
setRootPane(createRootPane()); |
|
649 |
setRootPaneCheckingEnabled(true); |
|
650 |
if (JDialog.isDefaultLookAndFeelDecorated()) { |
|
651 |
boolean supportsWindowDecorations = |
|
652 |
UIManager.getLookAndFeel().getSupportsWindowDecorations(); |
|
653 |
if (supportsWindowDecorations) { |
|
654 |
setUndecorated(true); |
|
655 |
getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); |
|
656 |
} |
|
657 |
} |
|
12661
6cf8b7116579
7125044: [macosx] Test failure because Component.transferFocus() works differently in applet and application.
ant
parents:
7500
diff
changeset
|
658 |
sun.awt.SunToolkit.checkAndSetPolicy(this); |
2 | 659 |
} |
660 |
||
661 |
/** |
|
662 |
* Called by the constructor methods to create the default |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
663 |
* {@code rootPane}. |
2 | 664 |
*/ |
665 |
protected JRootPane createRootPane() { |
|
666 |
JRootPane rp = new JRootPane(); |
|
667 |
// NOTE: this uses setOpaque vs LookAndFeel.installProperty as there |
|
668 |
// is NO reason for the RootPane not to be opaque. For painting to |
|
669 |
// work the contentPane must be opaque, therefor the RootPane can |
|
670 |
// also be opaque. |
|
671 |
rp.setOpaque(true); |
|
672 |
return rp; |
|
673 |
} |
|
674 |
||
675 |
/** |
|
676 |
* Handles window events depending on the state of the |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
677 |
* {@code defaultCloseOperation} property. |
2 | 678 |
* |
679 |
* @see #setDefaultCloseOperation |
|
680 |
*/ |
|
681 |
protected void processWindowEvent(WindowEvent e) { |
|
682 |
super.processWindowEvent(e); |
|
683 |
||
684 |
if (e.getID() == WindowEvent.WINDOW_CLOSING) { |
|
685 |
switch(defaultCloseOperation) { |
|
686 |
case HIDE_ON_CLOSE: |
|
687 |
setVisible(false); |
|
688 |
break; |
|
689 |
case DISPOSE_ON_CLOSE: |
|
690 |
dispose(); |
|
691 |
break; |
|
692 |
case DO_NOTHING_ON_CLOSE: |
|
693 |
default: |
|
694 |
break; |
|
695 |
} |
|
696 |
} |
|
697 |
} |
|
698 |
||
699 |
||
700 |
/** |
|
701 |
* Sets the operation that will happen by default when |
|
702 |
* the user initiates a "close" on this dialog. |
|
703 |
* You must specify one of the following choices: |
|
704 |
* <p> |
|
705 |
* <ul> |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
706 |
* <li>{@code DO_NOTHING_ON_CLOSE} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
707 |
* (defined in {@code WindowConstants}): |
2 | 708 |
* Don't do anything; require the |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
709 |
* program to handle the operation in the {@code windowClosing} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
710 |
* method of a registered {@code WindowListener} object. |
2 | 711 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
712 |
* <li>{@code HIDE_ON_CLOSE} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
713 |
* (defined in {@code WindowConstants}): |
2 | 714 |
* Automatically hide the dialog after |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
715 |
* invoking any registered {@code WindowListener} |
2 | 716 |
* objects. |
717 |
* |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
718 |
* <li>{@code DISPOSE_ON_CLOSE} |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
719 |
* (defined in {@code WindowConstants}): |
2 | 720 |
* Automatically hide and dispose the |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
721 |
* dialog after invoking any registered {@code WindowListener} |
2 | 722 |
* objects. |
723 |
* </ul> |
|
724 |
* <p> |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
725 |
* The value is set to {@code HIDE_ON_CLOSE} by default. Changes |
2 | 726 |
* to the value of this property cause the firing of a property |
727 |
* change event, with property name "defaultCloseOperation". |
|
728 |
* <p> |
|
729 |
* <b>Note</b>: When the last displayable window within the |
|
730 |
* Java virtual machine (VM) is disposed of, the VM may |
|
731 |
* terminate. See <a href="../../java/awt/doc-files/AWTThreadIssues.html"> |
|
732 |
* AWT Threading Issues</a> for more information. |
|
733 |
* |
|
734 |
* @param operation the operation which should be performed when the |
|
735 |
* user closes the dialog |
|
736 |
* @throws IllegalArgumentException if defaultCloseOperation value |
|
737 |
* isn't one of the above valid values |
|
738 |
* @see #addWindowListener |
|
739 |
* @see #getDefaultCloseOperation |
|
740 |
* @see WindowConstants |
|
741 |
* |
|
742 |
* @beaninfo |
|
743 |
* preferred: true |
|
744 |
* bound: true |
|
745 |
* enum: DO_NOTHING_ON_CLOSE WindowConstants.DO_NOTHING_ON_CLOSE |
|
746 |
* HIDE_ON_CLOSE WindowConstants.HIDE_ON_CLOSE |
|
747 |
* DISPOSE_ON_CLOSE WindowConstants.DISPOSE_ON_CLOSE |
|
748 |
* description: The dialog's default close operation. |
|
749 |
*/ |
|
750 |
public void setDefaultCloseOperation(int operation) { |
|
751 |
if (operation != DO_NOTHING_ON_CLOSE && |
|
752 |
operation != HIDE_ON_CLOSE && |
|
753 |
operation != DISPOSE_ON_CLOSE) { |
|
754 |
throw new IllegalArgumentException("defaultCloseOperation must be one of: DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, or DISPOSE_ON_CLOSE"); |
|
755 |
} |
|
756 |
||
757 |
int oldValue = this.defaultCloseOperation; |
|
758 |
this.defaultCloseOperation = operation; |
|
759 |
firePropertyChange("defaultCloseOperation", oldValue, operation); |
|
760 |
} |
|
761 |
||
762 |
/** |
|
763 |
* Returns the operation which occurs when the user |
|
764 |
* initiates a "close" on this dialog. |
|
765 |
* |
|
766 |
* @return an integer indicating the window-close operation |
|
767 |
* @see #setDefaultCloseOperation |
|
768 |
*/ |
|
769 |
public int getDefaultCloseOperation() { |
|
770 |
return defaultCloseOperation; |
|
771 |
} |
|
772 |
||
773 |
/** |
|
774 |
* Sets the {@code transferHandler} property, which is a mechanism to |
|
775 |
* support transfer of data into this component. Use {@code null} |
|
776 |
* if the component does not support data transfer operations. |
|
777 |
* <p> |
|
778 |
* If the system property {@code suppressSwingDropSupport} is {@code false} |
|
779 |
* (the default) and the current drop target on this component is either |
|
780 |
* {@code null} or not a user-set drop target, this method will change the |
|
781 |
* drop target as follows: If {@code newHandler} is {@code null} it will |
|
782 |
* clear the drop target. If not {@code null} it will install a new |
|
783 |
* {@code DropTarget}. |
|
784 |
* <p> |
|
785 |
* Note: When used with {@code JDialog}, {@code TransferHandler} only |
|
786 |
* provides data import capability, as the data export related methods |
|
787 |
* are currently typed to {@code JComponent}. |
|
788 |
* <p> |
|
789 |
* Please see |
|
20455
f6f9a0c2796b
8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents:
12661
diff
changeset
|
790 |
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/dnd/index.html"> |
2 | 791 |
* How to Use Drag and Drop and Data Transfer</a>, a section in |
792 |
* <em>The Java Tutorial</em>, for more information. |
|
793 |
* |
|
794 |
* @param newHandler the new {@code TransferHandler} |
|
795 |
* |
|
796 |
* @see TransferHandler |
|
797 |
* @see #getTransferHandler |
|
798 |
* @see java.awt.Component#setDropTarget |
|
799 |
* @since 1.6 |
|
800 |
* |
|
801 |
* @beaninfo |
|
802 |
* bound: true |
|
803 |
* hidden: true |
|
804 |
* description: Mechanism for transfer of data into the component |
|
805 |
*/ |
|
806 |
public void setTransferHandler(TransferHandler newHandler) { |
|
807 |
TransferHandler oldHandler = transferHandler; |
|
808 |
transferHandler = newHandler; |
|
809 |
SwingUtilities.installSwingDropTargetAsNecessary(this, transferHandler); |
|
810 |
firePropertyChange("transferHandler", oldHandler, newHandler); |
|
811 |
} |
|
812 |
||
813 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
814 |
* Gets the {@code transferHandler} property. |
2 | 815 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
816 |
* @return the value of the {@code transferHandler} property |
2 | 817 |
* |
818 |
* @see TransferHandler |
|
819 |
* @see #setTransferHandler |
|
820 |
* @since 1.6 |
|
821 |
*/ |
|
822 |
public TransferHandler getTransferHandler() { |
|
823 |
return transferHandler; |
|
824 |
} |
|
825 |
||
826 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
827 |
* Calls {@code paint(g)}. This method was overridden to |
2 | 828 |
* prevent an unnecessary call to clear the background. |
829 |
* |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
830 |
* @param g the {@code Graphics} context in which to paint |
2 | 831 |
*/ |
832 |
public void update(Graphics g) { |
|
833 |
paint(g); |
|
834 |
} |
|
835 |
||
836 |
/** |
|
837 |
* Sets the menubar for this dialog. |
|
838 |
* |
|
839 |
* @param menu the menubar being placed in the dialog |
|
840 |
* |
|
841 |
* @see #getJMenuBar |
|
842 |
* |
|
843 |
* @beaninfo |
|
844 |
* hidden: true |
|
845 |
* description: The menubar for accessing pulldown menus from this dialog. |
|
846 |
*/ |
|
847 |
public void setJMenuBar(JMenuBar menu) { |
|
848 |
getRootPane().setMenuBar(menu); |
|
849 |
} |
|
850 |
||
851 |
/** |
|
852 |
* Returns the menubar set on this dialog. |
|
853 |
* |
|
854 |
* @see #setJMenuBar |
|
855 |
*/ |
|
856 |
public JMenuBar getJMenuBar() { |
|
857 |
return getRootPane().getMenuBar(); |
|
858 |
} |
|
859 |
||
860 |
||
861 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
862 |
* Returns whether calls to {@code add} and |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
863 |
* {@code setLayout} are forwarded to the {@code contentPane}. |
2 | 864 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
865 |
* @return true if {@code add} and {@code setLayout} |
2 | 866 |
* are fowarded; false otherwise |
867 |
* |
|
868 |
* @see #addImpl |
|
869 |
* @see #setLayout |
|
870 |
* @see #setRootPaneCheckingEnabled |
|
871 |
* @see javax.swing.RootPaneContainer |
|
872 |
*/ |
|
873 |
protected boolean isRootPaneCheckingEnabled() { |
|
874 |
return rootPaneCheckingEnabled; |
|
875 |
} |
|
876 |
||
877 |
||
878 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
879 |
* Sets whether calls to {@code add} and |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
880 |
* {@code setLayout} are forwarded to the {@code contentPane}. |
2 | 881 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
882 |
* @param enabled true if {@code add} and {@code setLayout} |
2 | 883 |
* are forwarded, false if they should operate directly on the |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
884 |
* {@code JDialog}. |
2 | 885 |
* |
886 |
* @see #addImpl |
|
887 |
* @see #setLayout |
|
888 |
* @see #isRootPaneCheckingEnabled |
|
889 |
* @see javax.swing.RootPaneContainer |
|
890 |
* @beaninfo |
|
891 |
* hidden: true |
|
892 |
* description: Whether the add and setLayout methods are forwarded |
|
893 |
*/ |
|
894 |
protected void setRootPaneCheckingEnabled(boolean enabled) { |
|
895 |
rootPaneCheckingEnabled = enabled; |
|
896 |
} |
|
897 |
||
898 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
899 |
* Adds the specified child {@code Component}. |
2 | 900 |
* This method is overridden to conditionally forward calls to the |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
901 |
* {@code contentPane}. |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
902 |
* By default, children are added to the {@code contentPane} instead |
2 | 903 |
* of the frame, refer to {@link javax.swing.RootPaneContainer} for |
904 |
* details. |
|
905 |
* |
|
906 |
* @param comp the component to be enhanced |
|
907 |
* @param constraints the constraints to be respected |
|
908 |
* @param index the index |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
909 |
* @throws IllegalArgumentException if {@code index} is invalid |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
910 |
* @throws IllegalArgumentException if adding the container's parent |
2 | 911 |
* to itself |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
912 |
* @throws IllegalArgumentException if adding a window to a container |
2 | 913 |
* |
914 |
* @see #setRootPaneCheckingEnabled |
|
915 |
* @see javax.swing.RootPaneContainer |
|
916 |
*/ |
|
917 |
protected void addImpl(Component comp, Object constraints, int index) |
|
918 |
{ |
|
919 |
if(isRootPaneCheckingEnabled()) { |
|
920 |
getContentPane().add(comp, constraints, index); |
|
921 |
} |
|
922 |
else { |
|
923 |
super.addImpl(comp, constraints, index); |
|
924 |
} |
|
925 |
} |
|
926 |
||
927 |
/** |
|
928 |
* Removes the specified component from the container. If |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
929 |
* {@code comp} is not the {@code rootPane}, this will forward |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
930 |
* the call to the {@code contentPane}. This will do nothing if |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
931 |
* {@code comp} is not a child of the {@code JDialog} or |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
932 |
* {@code contentPane}. |
2 | 933 |
* |
934 |
* @param comp the component to be removed |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
935 |
* @throws NullPointerException if {@code comp} is null |
2 | 936 |
* @see #add |
937 |
* @see javax.swing.RootPaneContainer |
|
938 |
*/ |
|
939 |
public void remove(Component comp) { |
|
940 |
if (comp == rootPane) { |
|
941 |
super.remove(comp); |
|
942 |
} else { |
|
943 |
getContentPane().remove(comp); |
|
944 |
} |
|
945 |
} |
|
946 |
||
947 |
||
948 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
949 |
* Sets the {@code LayoutManager}. |
2 | 950 |
* Overridden to conditionally forward the call to the |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
951 |
* {@code contentPane}. |
2 | 952 |
* Refer to {@link javax.swing.RootPaneContainer} for |
953 |
* more information. |
|
954 |
* |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
955 |
* @param manager the {@code LayoutManager} |
2 | 956 |
* @see #setRootPaneCheckingEnabled |
957 |
* @see javax.swing.RootPaneContainer |
|
958 |
*/ |
|
959 |
public void setLayout(LayoutManager manager) { |
|
960 |
if(isRootPaneCheckingEnabled()) { |
|
961 |
getContentPane().setLayout(manager); |
|
962 |
} |
|
963 |
else { |
|
964 |
super.setLayout(manager); |
|
965 |
} |
|
966 |
} |
|
967 |
||
968 |
||
969 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
970 |
* Returns the {@code rootPane} object for this dialog. |
2 | 971 |
* |
972 |
* @see #setRootPane |
|
973 |
* @see RootPaneContainer#getRootPane |
|
974 |
*/ |
|
975 |
public JRootPane getRootPane() { |
|
976 |
return rootPane; |
|
977 |
} |
|
978 |
||
979 |
||
980 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
981 |
* Sets the {@code rootPane} property. |
2 | 982 |
* This method is called by the constructor. |
983 |
* |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
984 |
* @param root the {@code rootPane} object for this dialog |
2 | 985 |
* |
986 |
* @see #getRootPane |
|
987 |
* |
|
988 |
* @beaninfo |
|
989 |
* hidden: true |
|
990 |
* description: the RootPane object for this dialog. |
|
991 |
*/ |
|
992 |
protected void setRootPane(JRootPane root) { |
|
993 |
if(rootPane != null) { |
|
994 |
remove(rootPane); |
|
995 |
} |
|
996 |
rootPane = root; |
|
997 |
if(rootPane != null) { |
|
998 |
boolean checkingEnabled = isRootPaneCheckingEnabled(); |
|
999 |
try { |
|
1000 |
setRootPaneCheckingEnabled(false); |
|
1001 |
add(rootPane, BorderLayout.CENTER); |
|
1002 |
} |
|
1003 |
finally { |
|
1004 |
setRootPaneCheckingEnabled(checkingEnabled); |
|
1005 |
} |
|
1006 |
} |
|
1007 |
} |
|
1008 |
||
1009 |
||
1010 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1011 |
* Returns the {@code contentPane} object for this dialog. |
2 | 1012 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1013 |
* @return the {@code contentPane} property |
2 | 1014 |
* |
1015 |
* @see #setContentPane |
|
1016 |
* @see RootPaneContainer#getContentPane |
|
1017 |
*/ |
|
1018 |
public Container getContentPane() { |
|
1019 |
return getRootPane().getContentPane(); |
|
1020 |
} |
|
1021 |
||
1022 |
||
1023 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1024 |
* Sets the {@code contentPane} property. |
2 | 1025 |
* This method is called by the constructor. |
1026 |
* <p> |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1027 |
* Swing's painting architecture requires an opaque {@code JComponent} |
2 | 1028 |
* in the containment hiearchy. This is typically provided by the |
1029 |
* content pane. If you replace the content pane it is recommended you |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1030 |
* replace it with an opaque {@code JComponent}. |
2 | 1031 |
* @see JRootPane |
1032 |
* |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1033 |
* @param contentPane the {@code contentPane} object for this dialog |
2 | 1034 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1035 |
* @throws java.awt.IllegalComponentStateException (a runtime |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1036 |
* exception) if the content pane parameter is {@code null} |
2 | 1037 |
* @see #getContentPane |
1038 |
* @see RootPaneContainer#setContentPane |
|
1039 |
* |
|
1040 |
* @beaninfo |
|
1041 |
* hidden: true |
|
1042 |
* description: The client area of the dialog where child |
|
1043 |
* components are normally inserted. |
|
1044 |
*/ |
|
1045 |
public void setContentPane(Container contentPane) { |
|
1046 |
getRootPane().setContentPane(contentPane); |
|
1047 |
} |
|
1048 |
||
1049 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1050 |
* Returns the {@code layeredPane} object for this dialog. |
2 | 1051 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1052 |
* @return the {@code layeredPane} property |
2 | 1053 |
* |
1054 |
* @see #setLayeredPane |
|
1055 |
* @see RootPaneContainer#getLayeredPane |
|
1056 |
*/ |
|
1057 |
public JLayeredPane getLayeredPane() { |
|
1058 |
return getRootPane().getLayeredPane(); |
|
1059 |
} |
|
1060 |
||
1061 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1062 |
* Sets the {@code layeredPane} property. |
2 | 1063 |
* This method is called by the constructor. |
1064 |
* |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1065 |
* @param layeredPane the new {@code layeredPane} property |
2 | 1066 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1067 |
* @throws java.awt.IllegalComponentStateException (a runtime |
2 | 1068 |
* exception) if the layered pane parameter is null |
1069 |
* @see #getLayeredPane |
|
1070 |
* @see RootPaneContainer#setLayeredPane |
|
1071 |
* |
|
1072 |
* @beaninfo |
|
1073 |
* hidden: true |
|
1074 |
* description: The pane which holds the various dialog layers. |
|
1075 |
*/ |
|
1076 |
public void setLayeredPane(JLayeredPane layeredPane) { |
|
1077 |
getRootPane().setLayeredPane(layeredPane); |
|
1078 |
} |
|
1079 |
||
1080 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1081 |
* Returns the {@code glassPane} object for this dialog. |
2 | 1082 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1083 |
* @return the {@code glassPane} property |
2 | 1084 |
* |
1085 |
* @see #setGlassPane |
|
1086 |
* @see RootPaneContainer#getGlassPane |
|
1087 |
*/ |
|
1088 |
public Component getGlassPane() { |
|
1089 |
return getRootPane().getGlassPane(); |
|
1090 |
} |
|
1091 |
||
1092 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1093 |
* Sets the {@code glassPane} property. |
2 | 1094 |
* This method is called by the constructor. |
1095 |
* |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1096 |
* @param glassPane the {@code glassPane} object for this dialog |
2 | 1097 |
* @see #getGlassPane |
1098 |
* @see RootPaneContainer#setGlassPane |
|
1099 |
* |
|
1100 |
* @beaninfo |
|
1101 |
* hidden: true |
|
1102 |
* description: A transparent pane used for menu rendering. |
|
1103 |
*/ |
|
1104 |
public void setGlassPane(Component glassPane) { |
|
1105 |
getRootPane().setGlassPane(glassPane); |
|
1106 |
} |
|
1107 |
||
1108 |
/** |
|
1109 |
* {@inheritDoc} |
|
1110 |
* |
|
1111 |
* @since 1.6 |
|
1112 |
*/ |
|
1113 |
public Graphics getGraphics() { |
|
1114 |
JComponent.getGraphicsInvoked(this); |
|
1115 |
return super.getGraphics(); |
|
1116 |
} |
|
1117 |
||
1118 |
/** |
|
1119 |
* Repaints the specified rectangle of this component within |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1120 |
* {@code time} milliseconds. Refer to {@code RepaintManager} |
2 | 1121 |
* for details on how the repaint is handled. |
1122 |
* |
|
1123 |
* @param time maximum time in milliseconds before update |
|
1124 |
* @param x the <i>x</i> coordinate |
|
1125 |
* @param y the <i>y</i> coordinate |
|
1126 |
* @param width the width |
|
1127 |
* @param height the height |
|
1128 |
* @see RepaintManager |
|
1129 |
* @since 1.6 |
|
1130 |
*/ |
|
1131 |
public void repaint(long time, int x, int y, int width, int height) { |
|
1132 |
if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) { |
|
1133 |
RepaintManager.currentManager(this).addDirtyRegion( |
|
1134 |
this, x, y, width, height); |
|
1135 |
} |
|
1136 |
else { |
|
1137 |
super.repaint(time, x, y, width, height); |
|
1138 |
} |
|
1139 |
} |
|
1140 |
||
1141 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1142 |
* Provides a hint as to whether or not newly created {@code JDialog}s |
2 | 1143 |
* should have their Window decorations (such as borders, widgets to |
1144 |
* close the window, title...) provided by the current look |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1145 |
* and feel. If {@code defaultLookAndFeelDecorated} is true, |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1146 |
* the current {@code LookAndFeel} supports providing window |
2 | 1147 |
* decorations, and the current window manager supports undecorated |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1148 |
* windows, then newly created {@code JDialog}s will have their |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1149 |
* Window decorations provided by the current {@code LookAndFeel}. |
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1150 |
* Otherwise, newly created {@code JDialog}s will have their |
2 | 1151 |
* Window decorations provided by the current window manager. |
1152 |
* <p> |
|
1153 |
* You can get the same effect on a single JDialog by doing the following: |
|
1154 |
* <pre> |
|
1155 |
* JDialog dialog = new JDialog(); |
|
1156 |
* dialog.setUndecorated(true); |
|
1157 |
* dialog.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); |
|
1158 |
* </pre> |
|
1159 |
* |
|
1160 |
* @param defaultLookAndFeelDecorated A hint as to whether or not current |
|
1161 |
* look and feel should provide window decorations |
|
1162 |
* @see javax.swing.LookAndFeel#getSupportsWindowDecorations |
|
1163 |
* @since 1.4 |
|
1164 |
*/ |
|
1165 |
public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated) { |
|
1166 |
if (defaultLookAndFeelDecorated) { |
|
1167 |
SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.TRUE); |
|
1168 |
} else { |
|
1169 |
SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.FALSE); |
|
1170 |
} |
|
1171 |
} |
|
1172 |
||
1173 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1174 |
* Returns true if newly created {@code JDialog}s should have their |
2 | 1175 |
* Window decorations provided by the current look and feel. This is only |
1176 |
* a hint, as certain look and feels may not support this feature. |
|
1177 |
* |
|
1178 |
* @return true if look and feel should provide Window decorations. |
|
1179 |
* @since 1.4 |
|
1180 |
*/ |
|
1181 |
public static boolean isDefaultLookAndFeelDecorated() { |
|
1182 |
Boolean defaultLookAndFeelDecorated = |
|
1183 |
(Boolean) SwingUtilities.appContextGet(defaultLookAndFeelDecoratedKey); |
|
1184 |
if (defaultLookAndFeelDecorated == null) { |
|
1185 |
defaultLookAndFeelDecorated = Boolean.FALSE; |
|
1186 |
} |
|
1187 |
return defaultLookAndFeelDecorated.booleanValue(); |
|
1188 |
} |
|
1189 |
||
1190 |
/** |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1191 |
* Returns a string representation of this {@code JDialog}. |
2 | 1192 |
* This method |
1193 |
* is intended to be used only for debugging purposes, and the |
|
1194 |
* content and format of the returned string may vary between |
|
1195 |
* implementations. The returned string may be empty but may not |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1196 |
* be {@code null}. |
2 | 1197 |
* |
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1198 |
* @return a string representation of this {@code JDialog}. |
2 | 1199 |
*/ |
1200 |
protected String paramString() { |
|
1201 |
String defaultCloseOperationString; |
|
1202 |
if (defaultCloseOperation == HIDE_ON_CLOSE) { |
|
1203 |
defaultCloseOperationString = "HIDE_ON_CLOSE"; |
|
1204 |
} else if (defaultCloseOperation == DISPOSE_ON_CLOSE) { |
|
1205 |
defaultCloseOperationString = "DISPOSE_ON_CLOSE"; |
|
1206 |
} else if (defaultCloseOperation == DO_NOTHING_ON_CLOSE) { |
|
1207 |
defaultCloseOperationString = "DO_NOTHING_ON_CLOSE"; |
|
1208 |
} else defaultCloseOperationString = ""; |
|
1209 |
String rootPaneString = (rootPane != null ? |
|
1210 |
rootPane.toString() : ""); |
|
1211 |
String rootPaneCheckingEnabledString = (rootPaneCheckingEnabled ? |
|
1212 |
"true" : "false"); |
|
1213 |
||
1214 |
return super.paramString() + |
|
1215 |
",defaultCloseOperation=" + defaultCloseOperationString + |
|
1216 |
",rootPane=" + rootPaneString + |
|
1217 |
",rootPaneCheckingEnabled=" + rootPaneCheckingEnabledString; |
|
1218 |
} |
|
1219 |
||
1220 |
||
1221 |
///////////////// |
|
1222 |
// Accessibility support |
|
1223 |
//////////////// |
|
1224 |
||
1225 |
protected AccessibleContext accessibleContext = null; |
|
1226 |
||
1227 |
/** |
|
1228 |
* Gets the AccessibleContext associated with this JDialog. |
|
1229 |
* For JDialogs, the AccessibleContext takes the form of an |
|
1230 |
* AccessibleJDialog. |
|
1231 |
* A new AccessibleJDialog instance is created if necessary. |
|
1232 |
* |
|
1233 |
* @return an AccessibleJDialog that serves as the |
|
1234 |
* AccessibleContext of this JDialog |
|
1235 |
*/ |
|
1236 |
public AccessibleContext getAccessibleContext() { |
|
1237 |
if (accessibleContext == null) { |
|
1238 |
accessibleContext = new AccessibleJDialog(); |
|
1239 |
} |
|
1240 |
return accessibleContext; |
|
1241 |
} |
|
1242 |
||
1243 |
/** |
|
1244 |
* This class implements accessibility support for the |
|
6511
1386b1b86562
6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents:
5506
diff
changeset
|
1245 |
* {@code JDialog} class. It provides an implementation of the |
2 | 1246 |
* Java Accessibility API appropriate to dialog user-interface |
1247 |
* elements. |
|
1248 |
*/ |
|
1249 |
protected class AccessibleJDialog extends AccessibleAWTDialog { |
|
1250 |
||
1251 |
// AccessibleContext methods |
|
1252 |
// |
|
1253 |
/** |
|
1254 |
* Get the accessible name of this object. |
|
1255 |
* |
|
1256 |
* @return the localized name of the object -- can be null if this |
|
1257 |
* object does not have a name |
|
1258 |
*/ |
|
1259 |
public String getAccessibleName() { |
|
1260 |
if (accessibleName != null) { |
|
1261 |
return accessibleName; |
|
1262 |
} else { |
|
1263 |
if (getTitle() == null) { |
|
1264 |
return super.getAccessibleName(); |
|
1265 |
} else { |
|
1266 |
return getTitle(); |
|
1267 |
} |
|
1268 |
} |
|
1269 |
} |
|
1270 |
||
1271 |
/** |
|
1272 |
* Get the state of this object. |
|
1273 |
* |
|
1274 |
* @return an instance of AccessibleStateSet containing the current |
|
1275 |
* state set of the object |
|
1276 |
* @see AccessibleState |
|
1277 |
*/ |
|
1278 |
public AccessibleStateSet getAccessibleStateSet() { |
|
1279 |
AccessibleStateSet states = super.getAccessibleStateSet(); |
|
1280 |
||
1281 |
if (isResizable()) { |
|
1282 |
states.add(AccessibleState.RESIZABLE); |
|
1283 |
} |
|
1284 |
if (getFocusOwner() != null) { |
|
1285 |
states.add(AccessibleState.ACTIVE); |
|
1286 |
} |
|
1287 |
if (isModal()) { |
|
1288 |
states.add(AccessibleState.MODAL); |
|
1289 |
} |
|
1290 |
return states; |
|
1291 |
} |
|
1292 |
||
1293 |
} // inner class AccessibleJDialog |
|
1294 |
} |