src/share/classes/javax/swing/DefaultDesktopManager.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2011, 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


 168     public void iconifyFrame(JInternalFrame f) {
 169         JInternalFrame.JDesktopIcon desktopIcon;
 170         Container c = f.getParent();
 171         JDesktopPane d = f.getDesktopPane();
 172         boolean findNext = f.isSelected();
 173         desktopIcon = f.getDesktopIcon();
 174         if(!wasIcon(f)) {
 175             Rectangle r = getBoundsForIconOf(f);
 176             desktopIcon.setBounds(r.x, r.y, r.width, r.height);
 177             // we must validate the hierarchy to not break the hw/lw mixing
 178             desktopIcon.revalidate();
 179             setWasIcon(f, Boolean.TRUE);
 180         }
 181 
 182         if (c == null || d == null) {
 183             return;
 184         }
 185 
 186         if (c instanceof JLayeredPane) {
 187             JLayeredPane lp = (JLayeredPane)c;
 188             int layer = lp.getLayer(f);
 189             lp.putLayer(desktopIcon, layer);
 190         }
 191 
 192         // If we are maximized we already have the normal bounds recorded
 193         // don't try to re-record them, otherwise we incorrectly set the
 194         // normal bounds to maximized state.
 195         if (!f.isMaximum()) {
 196             f.setNormalBounds(f.getBounds());
 197         }
 198         d.setComponentOrderCheckingEnabled(false);
 199         c.remove(f);
 200         c.add(desktopIcon);
 201         d.setComponentOrderCheckingEnabled(true);
 202         c.repaint(f.getX(), f.getY(), f.getWidth(), f.getHeight());
 203         if (findNext) {
 204             if (d.selectFrame(true) == null) {
 205                 // The icon is the last frame.
 206                 f.restoreSubcomponentFocus();
 207             }
 208         }
 209     }


   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


 168     public void iconifyFrame(JInternalFrame f) {
 169         JInternalFrame.JDesktopIcon desktopIcon;
 170         Container c = f.getParent();
 171         JDesktopPane d = f.getDesktopPane();
 172         boolean findNext = f.isSelected();
 173         desktopIcon = f.getDesktopIcon();
 174         if(!wasIcon(f)) {
 175             Rectangle r = getBoundsForIconOf(f);
 176             desktopIcon.setBounds(r.x, r.y, r.width, r.height);
 177             // we must validate the hierarchy to not break the hw/lw mixing
 178             desktopIcon.revalidate();
 179             setWasIcon(f, Boolean.TRUE);
 180         }
 181 
 182         if (c == null || d == null) {
 183             return;
 184         }
 185 
 186         if (c instanceof JLayeredPane) {
 187             JLayeredPane lp = (JLayeredPane)c;
 188             int layer = JLayeredPane.getLayer(f);
 189             JLayeredPane.putLayer(desktopIcon, layer);
 190         }
 191 
 192         // If we are maximized we already have the normal bounds recorded
 193         // don't try to re-record them, otherwise we incorrectly set the
 194         // normal bounds to maximized state.
 195         if (!f.isMaximum()) {
 196             f.setNormalBounds(f.getBounds());
 197         }
 198         d.setComponentOrderCheckingEnabled(false);
 199         c.remove(f);
 200         c.add(desktopIcon);
 201         d.setComponentOrderCheckingEnabled(true);
 202         c.repaint(f.getX(), f.getY(), f.getWidth(), f.getHeight());
 203         if (findNext) {
 204             if (d.selectFrame(true) == null) {
 205                 // The icon is the last frame.
 206                 f.restoreSubcomponentFocus();
 207             }
 208         }
 209     }