1 /* 2 * Copyright (c) 1997, 2015, 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 /** DesktopManager objects are owned by a JDesktopPane object. They are responsible 29 * for implementing L&F specific behaviors for the JDesktopPane. JInternalFrame 30 * implementations should delegate specific behaviors to the DesktopManager. For 31 * instance, if a JInternalFrame was asked to iconify, it should try: 32 * <PRE> 33 * getDesktopPane().getDesktopManager().iconifyFrame(frame); 34 * </PRE> 35 * This delegation allows each L&F to provide custom behaviors for desktop-specific 36 * actions. (For example, how and where the internal frame's icon would appear.) 37 * <p>This class provides a policy for the various JInternalFrame methods, it is not 38 * meant to be called directly rather the various JInternalFrame methods will call 39 * into the DesktopManager.</p> 40 * 41 * @see JDesktopPane 42 * @see JInternalFrame 43 * @see JInternalFrame.JDesktopIcon 44 * 45 * @author David Kloba 46 * @since 1.2 47 */ 48 public interface DesktopManager 49 { 50 /** 51 * If possible, display this frame in an appropriate location. 52 * Normally, this is not called, as the creator of the JInternalFrame 53 * will add the frame to the appropriate parent. 54 * 55 * @param f the {@code JInternalFrame} to be displayed 56 */ 57 void openFrame(JInternalFrame f); 58 59 /** 60 * Generally, this call should remove the frame from its parent. 61 * 62 * @param f the {@code JInternalFrame} to be removed 63 */ 64 void closeFrame(JInternalFrame f); 65 66 /** 67 * Generally, the frame should be resized to match its parents bounds. 68 * 69 * @param f the {@code JInternalFrame} to be resized 70 */ 71 void maximizeFrame(JInternalFrame f); 72 73 /** 74 * Generally, this indicates that the frame should be restored to its 75 * size and position prior to a maximizeFrame() call. 76 * 77 * @param f the {@code JInternalFrame} to be restored 78 */ 79 void minimizeFrame(JInternalFrame f); 80 81 /** 82 * Generally, remove this frame from its parent and add an iconic representation. 83 * 84 * @param f the {@code JInternalFrame} to be iconified 85 */ 86 void iconifyFrame(JInternalFrame f); 87 88 /** 89 * Generally, remove any iconic representation that is present and restore the 90 * frame to it's original size and location. 91 * 92 * @param f the {@code JInternalFrame} to be de-iconified 93 */ 94 void deiconifyFrame(JInternalFrame f); 95 96 /** 97 * Generally, indicate that this frame has focus. This is usually called after 98 * the JInternalFrame's IS_SELECTED_PROPERTY has been set to true. 99 * 100 * @param f the {@code JInternalFrame} to be activated 101 */ 102 void activateFrame(JInternalFrame f); 103 104 /** 105 * Generally, indicate that this frame has lost focus. This is usually called 106 * after the JInternalFrame's IS_SELECTED_PROPERTY has been set to false. 107 * 108 * @param f the {@code JInternalFrame} to be deactivated 109 */ 110 void deactivateFrame(JInternalFrame f); 111 112 /** 113 * This method is normally called when the user has indicated that 114 * they will begin dragging a component around. This method should be called 115 * prior to any dragFrame() calls to allow the DesktopManager to prepare any 116 * necessary state. Normally <b>f</b> will be a JInternalFrame. 117 * 118 * @param f the {@code JComponent} being dragged 119 */ 120 void beginDraggingFrame(JComponent f); 121 122 /** 123 * The user has moved the frame. Calls to this method will be preceded by calls 124 * to beginDraggingFrame(). 125 * Normally <b>f</b> will be a JInternalFrame. 126 * 127 * @param f the {@code JComponent} being dragged 128 * @param newX the new x-coordinate 129 * @param newY the new y-coordinate 130 */ 131 void dragFrame(JComponent f, int newX, int newY); 132 133 /** 134 * This method signals the end of the dragging session. Any state maintained by 135 * the DesktopManager can be removed here. Normally <b>f</b> will be a JInternalFrame. 136 * 137 * @param f the {@code JComponent} being dragged 138 */ 139 void endDraggingFrame(JComponent f); 140 141 /** 142 * This method is normally called when the user has indicated that 143 * they will begin resizing the frame. This method should be called 144 * prior to any resizeFrame() calls to allow the DesktopManager to prepare any 145 * necessary state. Normally <b>f</b> will be a JInternalFrame. 146 * 147 * @param f the {@code JComponent} being resized 148 * @param direction the direction 149 */ 150 void beginResizingFrame(JComponent f, int direction); 151 152 /** 153 * The user has resized the component. Calls to this method will be preceded by calls 154 * to beginResizingFrame(). 155 * Normally <b>f</b> will be a JInternalFrame. 156 * 157 * @param f the {@code JComponent} being resized 158 * @param newX the new x-coordinate 159 * @param newY the new y-coordinate 160 * @param newWidth the new width 161 * @param newHeight the new height 162 */ 163 void resizeFrame(JComponent f, int newX, int newY, int newWidth, int newHeight); 164 165 /** 166 * This method signals the end of the resize session. Any state maintained by 167 * the DesktopManager can be removed here. Normally <b>f</b> will be a JInternalFrame. 168 * 169 * @param f the {@code JComponent} being resized 170 */ 171 void endResizingFrame(JComponent f); 172 173 /** 174 * This is a primitive reshape method. 175 * 176 * @param f the {@code JComponent} being moved or resized 177 * @param newX the new x-coordinate 178 * @param newY the new y-coordinate 179 * @param newWidth the new width 180 * @param newHeight the new height 181 */ 182 void setBoundsForFrame(JComponent f, int newX, int newY, int newWidth, int newHeight); 183 }