1 /*
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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
211 Component createComponent(Component owner) {
212 if (GraphicsEnvironment.isHeadless()) {
213 // Generally not useful, bail.
214 return null;
215 }
216 return new HeavyWeightWindow(getParentWindow(owner));
217 }
218
219 /**
220 * Returns the <code>Component</code> returned from
221 * <code>createComponent</code> that will hold the <code>Popup</code>.
222 */
223 Component getComponent() {
224 return component;
225 }
226
227
228 /**
229 * Component used to house window.
230 */
231 static class HeavyWeightWindow extends JWindow implements ModalExclude {
232 HeavyWeightWindow(Window parent) {
233 super(parent);
234 setFocusableWindowState(false);
235 setType(Window.Type.POPUP);
236
237 // Popups are typically transient and most likely won't benefit
238 // from true double buffering. Turn it off here.
239 getRootPane().setUseTrueDoubleBuffering(false);
240 // Try to set "always-on-top" for the popup window.
241 // Applets usually don't have sufficient permissions to do it.
242 // In this case simply ignore the exception.
243 try {
244 setAlwaysOnTop(true);
245 } catch (SecurityException se) {
246 // setAlwaysOnTop is restricted,
247 // the exception is ignored
248 }
249 }
250
251 public void update(Graphics g) {
252 paint(g);
253 }
254
255 public void show() {
256 this.pack();
257 if (getWidth() > 0 && getHeight() > 0) {
258 super.show();
259 }
260 }
261 }
262
263
264 /**
265 * Used if no valid Window ancestor of the supplied owner is found.
266 * <p>
267 * PopupFactory uses this as a way to know when the Popup shouldn't
268 * be cached based on the Window.
269 */
270 static class DefaultFrame extends Frame {
271 }
272 }
|
1 /*
2 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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
211 Component createComponent(Component owner) {
212 if (GraphicsEnvironment.isHeadless()) {
213 // Generally not useful, bail.
214 return null;
215 }
216 return new HeavyWeightWindow(getParentWindow(owner));
217 }
218
219 /**
220 * Returns the <code>Component</code> returned from
221 * <code>createComponent</code> that will hold the <code>Popup</code>.
222 */
223 Component getComponent() {
224 return component;
225 }
226
227
228 /**
229 * Component used to house window.
230 */
231 @SuppressWarnings("serial") // Superclass is not serializable across versions
232 static class HeavyWeightWindow extends JWindow implements ModalExclude {
233 HeavyWeightWindow(Window parent) {
234 super(parent);
235 setFocusableWindowState(false);
236 setType(Window.Type.POPUP);
237
238 // Popups are typically transient and most likely won't benefit
239 // from true double buffering. Turn it off here.
240 getRootPane().setUseTrueDoubleBuffering(false);
241 // Try to set "always-on-top" for the popup window.
242 // Applets usually don't have sufficient permissions to do it.
243 // In this case simply ignore the exception.
244 try {
245 setAlwaysOnTop(true);
246 } catch (SecurityException se) {
247 // setAlwaysOnTop is restricted,
248 // the exception is ignored
249 }
250 }
251
252 public void update(Graphics g) {
253 paint(g);
254 }
255
256 public void show() {
257 this.pack();
258 if (getWidth() > 0 && getHeight() > 0) {
259 super.show();
260 }
261 }
262 }
263
264
265 /**
266 * Used if no valid Window ancestor of the supplied owner is found.
267 * <p>
268 * PopupFactory uses this as a way to know when the Popup shouldn't
269 * be cached based on the Window.
270 */
271 @SuppressWarnings("serial") // JDK-implementation class
272 static class DefaultFrame extends Frame {
273 }
274 }
|