1 /*
2 * Copyright (c) 1997, 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
23 * questions.
24 */
25
26
27 package javax.swing;
28
29 import com.sun.awt.AWTUtilities;
30 import sun.awt.AWTAccessor;
31 import sun.awt.SunToolkit;
32
33 import java.awt.*;
34 import java.beans.PropertyVetoException;
35
36 /** This is an implementation of the <code>DesktopManager</code>.
37 * It currently implements the basic behaviors for managing
38 * <code>JInternalFrame</code>s in an arbitrary parent.
39 * <code>JInternalFrame</code>s that are not children of a
40 * <code>JDesktop</code> will use this component
41 * to handle their desktop-like actions.
42 * <p>This class provides a policy for the various JInternalFrame methods,
43 * it is not meant to be called directly rather the various JInternalFrame
44 * methods will call into the DesktopManager.</p>
45 * @see JDesktopPane
46 * @see JInternalFrame
47 * @author David Kloba
48 * @author Steve Wilson
49 * @since 1.2
50 */
51 @SuppressWarnings("serial") // No Interesting Non-Transient State
52 public class DefaultDesktopManager implements DesktopManager, java.io.Serializable {
53 static final String HAS_BEEN_ICONIFIED_PROPERTY = "wasIconOnce";
54
55 static final int DEFAULT_DRAG_MODE = 0;
298 desktopBounds = ((JComponent)desktop).getVisibleRect();
299 }
300 else {
301 desktopBounds = desktop.getBounds();
302 desktopBounds.x = desktopBounds.y = 0;
303 }
304 desktopGraphics = JComponent.safelyGetGraphics(desktop);
305 ((JInternalFrame)f).isDragging = true;
306 didDrag = false;
307 }
308
309 }
310
311 private void setupDragMode(JComponent f) {
312 JDesktopPane p = getDesktopPane(f);
313 Container parent = f.getParent();
314 dragMode = DEFAULT_DRAG_MODE;
315 if (p != null) {
316 String mode = (String)p.getClientProperty("JDesktopPane.dragMode");
317 Window window = SwingUtilities.getWindowAncestor(f);
318 if (window != null && !AWTUtilities.isWindowOpaque(window)) {
319 dragMode = DEFAULT_DRAG_MODE;
320 } else if (mode != null && mode.equals("outline")) {
321 dragMode = OUTLINE_DRAG_MODE;
322 } else if (mode != null && mode.equals("faster")
323 && f instanceof JInternalFrame
324 && ((JInternalFrame)f).isOpaque() &&
325 (parent == null || parent.isOpaque())) {
326 dragMode = FASTER_DRAG_MODE;
327 } else {
328 if (p.getDragMode() == JDesktopPane.OUTLINE_DRAG_MODE ) {
329 dragMode = OUTLINE_DRAG_MODE;
330 } else if ( p.getDragMode() == JDesktopPane.LIVE_DRAG_MODE
331 && f instanceof JInternalFrame
332 && ((JInternalFrame)f).isOpaque()) {
333 dragMode = FASTER_DRAG_MODE;
334 } else {
335 dragMode = DEFAULT_DRAG_MODE;
336 }
337 }
338 }
|
1 /*
2 * Copyright (c) 1997, 2017, 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
23 * questions.
24 */
25
26 package javax.swing;
27
28 import java.awt.Color;
29 import java.awt.Component;
30 import java.awt.Container;
31 import java.awt.Dimension;
32 import java.awt.Graphics;
33 import java.awt.Point;
34 import java.awt.Rectangle;
35 import java.awt.Toolkit;
36 import java.awt.Window;
37 import java.beans.PropertyVetoException;
38
39 import sun.awt.AWTAccessor;
40 import sun.awt.SunToolkit;
41
42 /** This is an implementation of the <code>DesktopManager</code>.
43 * It currently implements the basic behaviors for managing
44 * <code>JInternalFrame</code>s in an arbitrary parent.
45 * <code>JInternalFrame</code>s that are not children of a
46 * <code>JDesktop</code> will use this component
47 * to handle their desktop-like actions.
48 * <p>This class provides a policy for the various JInternalFrame methods,
49 * it is not meant to be called directly rather the various JInternalFrame
50 * methods will call into the DesktopManager.</p>
51 * @see JDesktopPane
52 * @see JInternalFrame
53 * @author David Kloba
54 * @author Steve Wilson
55 * @since 1.2
56 */
57 @SuppressWarnings("serial") // No Interesting Non-Transient State
58 public class DefaultDesktopManager implements DesktopManager, java.io.Serializable {
59 static final String HAS_BEEN_ICONIFIED_PROPERTY = "wasIconOnce";
60
61 static final int DEFAULT_DRAG_MODE = 0;
304 desktopBounds = ((JComponent)desktop).getVisibleRect();
305 }
306 else {
307 desktopBounds = desktop.getBounds();
308 desktopBounds.x = desktopBounds.y = 0;
309 }
310 desktopGraphics = JComponent.safelyGetGraphics(desktop);
311 ((JInternalFrame)f).isDragging = true;
312 didDrag = false;
313 }
314
315 }
316
317 private void setupDragMode(JComponent f) {
318 JDesktopPane p = getDesktopPane(f);
319 Container parent = f.getParent();
320 dragMode = DEFAULT_DRAG_MODE;
321 if (p != null) {
322 String mode = (String)p.getClientProperty("JDesktopPane.dragMode");
323 Window window = SwingUtilities.getWindowAncestor(f);
324 if (window != null && !window.isOpaque()) {
325 dragMode = DEFAULT_DRAG_MODE;
326 } else if (mode != null && mode.equals("outline")) {
327 dragMode = OUTLINE_DRAG_MODE;
328 } else if (mode != null && mode.equals("faster")
329 && f instanceof JInternalFrame
330 && ((JInternalFrame)f).isOpaque() &&
331 (parent == null || parent.isOpaque())) {
332 dragMode = FASTER_DRAG_MODE;
333 } else {
334 if (p.getDragMode() == JDesktopPane.OUTLINE_DRAG_MODE ) {
335 dragMode = OUTLINE_DRAG_MODE;
336 } else if ( p.getDragMode() == JDesktopPane.LIVE_DRAG_MODE
337 && f instanceof JInternalFrame
338 && ((JInternalFrame)f).isOpaque()) {
339 dragMode = FASTER_DRAG_MODE;
340 } else {
341 dragMode = DEFAULT_DRAG_MODE;
342 }
343 }
344 }
|