⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaultdesktopmanager.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* DefaultDesktopManager.java --   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package javax.swing;import java.awt.Component;import java.awt.Container;import java.awt.Dimension;import java.awt.Insets;import java.awt.Rectangle;import java.beans.PropertyVetoException;import java.io.Serializable;import javax.swing.JInternalFrame.JDesktopIcon;/** * The default implementation of DesktopManager for * Swing. It implements the basic beaviours for JInternalFrames in arbitrary * parents. The methods provided by the class are not meant to be called by * the user, instead, the JInternalFrame methods will call these methods. */public class DefaultDesktopManager implements DesktopManager, Serializable{  /** DOCUMENT ME! */  private static final long serialVersionUID = 4657624909838017887L;  /** The property change event fired when the wasIcon property changes. */  static final String WAS_ICON_ONCE_PROPERTY = "wasIconOnce";  /**   * The method of dragging used by the JDesktopPane that parents the   * JInternalFrame that is being dragged.   */  private int currentDragMode = 0;  /**   * The cache of the bounds used to draw the outline rectangle when   * OUTLINE_DRAG_MODE is used.   */  private transient Rectangle dragCache = new Rectangle();  /**   * A cached JDesktopPane that is stored when the JInternalFrame is initially   * dragged.   */  private transient Container pane;  /**   * An array of Rectangles that holds the bounds of the JDesktopIcons in the   * JDesktopPane when looking for where to place a new icon.   */  private transient Rectangle[] iconRects;  /**   * This creates a new DefaultDesktopManager object.   */  public DefaultDesktopManager()  {    // Nothing to do here.  }  /**   * This method is not normally called since the user will typically add the   * JInternalFrame to a Container. If this is called, it will try to   * determine the parent of the JInternalFrame and remove any icon that   * represents this JInternalFrame and add this JInternalFrame.   *   * @param frame The JInternalFrame to open.   */  public void openFrame(JInternalFrame frame)  {    Container c = frame.getParent();    if (c == null)      c = frame.getDesktopIcon().getParent();    if (c == null)      return;    c.remove(frame.getDesktopIcon());    c.add(frame);    frame.setVisible(true);  }  /**   * This method removes the JInternalFrame and JDesktopIcon (if one is   * present) from their parents.   *   * @param frame The JInternalFrame to close.   */  public void closeFrame(JInternalFrame frame)  {    Container c = frame.getParent();    frame.doDefaultCloseAction();    if (c != null)      {	if (frame.isIcon())	  c.remove(frame.getDesktopIcon());	else	  c.remove(frame);	c.repaint();      }  }  /**   * This method resizes the JInternalFrame to match its parent's bounds.   *   * @param frame The JInternalFrame to maximize.   */  public void maximizeFrame(JInternalFrame frame)  {    // Can't maximize from iconified state.    // It can only return to maximized state, but that would fall under    // deiconify.    if (frame.isIcon())      return;    frame.setNormalBounds(frame.getBounds());    Container p = frame.getParent();    if (p != null)      {	Rectangle pBounds = p.getBounds();	Insets insets = p.getInsets();	pBounds.width -= insets.left + insets.right;	pBounds.height -= insets.top + insets.bottom;	setBoundsForFrame(frame, 0, 0, pBounds.width, pBounds.height);      }    if (p instanceof JDesktopPane)      ((JDesktopPane) p).setSelectedFrame(frame);    else      {	try	  {	    frame.setSelected(true);	  }	catch (PropertyVetoException e)	  {	    // Do nothing.	  }      }  }  /**   * This method restores the JInternalFrame's bounds to what they were   * previous to the setMaximize call.   *   * @param frame The JInternalFrame to minimize.   */  public void minimizeFrame(JInternalFrame frame)  {    Rectangle normalBounds = frame.getNormalBounds();    JDesktopPane p = frame.getDesktopPane();    if (p != null)      p.setSelectedFrame(frame);    else      {        try          {            frame.setSelected(true);          }        catch (PropertyVetoException e)          {            // Do nothing.          }      }    setBoundsForFrame(frame, normalBounds.x, normalBounds.y,                      normalBounds.width, normalBounds.height);  }  /**   * This method removes the JInternalFrame from its parent and adds its   * JDesktopIcon representation.   *   * @param frame The JInternalFrame to iconify.   */  public void iconifyFrame(JInternalFrame frame)  {    JDesktopPane p = frame.getDesktopPane();    JDesktopIcon icon = frame.getDesktopIcon();    if (p != null && p.getSelectedFrame() == frame)      p.setSelectedFrame(null);    else      {        try          {            frame.setSelected(false);          }        catch (PropertyVetoException e)          {            // Do nothing if attempt is vetoed.          }      }    Container c = frame.getParent();    if (!wasIcon(frame))      {        Rectangle r = getBoundsForIconOf(frame);        icon.setBounds(r);        setWasIcon(frame, Boolean.TRUE);      }    if (c != null)      {        if (icon != null)          {            c.add(icon);            icon.setVisible(true);          }        c.remove(frame);      }  }  /**   * This method removes the JInternalFrame's JDesktopIcon representation and   * adds the JInternalFrame back to its parent.   *   * @param frame The JInternalFrame to deiconify.   */  public void deiconifyFrame(JInternalFrame frame)  {    JDesktopIcon icon = frame.getDesktopIcon();    Container c = icon.getParent();    removeIconFor(frame);    c.add(frame);    frame.setVisible(true);    if (!frame.isSelected())      {        JDesktopPane p = frame.getDesktopPane();        if (p != null)          p.setSelectedFrame(frame);        else          {            try              {                frame.setSelected(true);              }            catch (PropertyVetoException e)              {                // Do nothing.              }          }      }    c.invalidate();  }  /**   * This method activates the JInternalFrame by moving it to the front and   * selecting it.   *   * @param frame The JInternalFrame to activate.   */  public void activateFrame(JInternalFrame frame)  {    JDesktopPane p = frame.getDesktopPane();    if (p != null)      p.setSelectedFrame(frame);    else      {        try          {            frame.setSelected(true);          }        catch (PropertyVetoException e)          {            // Do nothing if attempt is vetoed.          }      }    frame.toFront();  }  /**   * This method is called when the JInternalFrame loses focus.   *   * @param frame The JInternalFram to deactivate.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -