コード例 #1
0
 /**
  * Removes the frame, and, if necessary, the <code>desktopIcon</code>, from its parent.
  *
  * @param f the <code>JInternalFrame</code> to be removed
  */
 public void closeFrame(JInternalFrame f) {
   JDesktopPane d = f.getDesktopPane();
   if (d == null) {
     return;
   }
   boolean findNext = f.isSelected();
   Container c = f.getParent();
   JInternalFrame nextFrame = null;
   if (findNext) {
     nextFrame = d.getNextFrame(f);
     try {
       f.setSelected(false);
     } catch (PropertyVetoException e2) {
     }
   }
   if (c != null) {
     c.remove(f); // Removes the focus.
     c.repaint(f.getX(), f.getY(), f.getWidth(), f.getHeight());
   }
   removeIconFor(f);
   if (f.getNormalBounds() != null) f.setNormalBounds(null);
   if (wasIcon(f)) setWasIcon(f, null);
   if (nextFrame != null) {
     try {
       nextFrame.setSelected(true);
     } catch (PropertyVetoException e2) {
     }
   } else if (findNext && d.getComponentCount() == 0) {
     // It was selected and was the last component on the desktop.
     d.requestFocus();
   }
 }
コード例 #2
0
  /**
   * maximizes the internal frame to the viewport bounds rather than the desktop bounds
   *
   * @param f the internal frame being maximized
   */
  public void maximizeFrame(JInternalFrame f) {

    Rectangle p = desktopPane.getScrollPaneRectangle();
    f.setNormalBounds(f.getBounds());
    setBoundsForFrame(f, p.x, p.y, p.width, p.height);
    try {
      f.setSelected(true);
    } catch (PropertyVetoException pve) {
      System.out.println(pve.getMessage());
    }

    removeIconFor(f);
  }
コード例 #3
0
  /**
   * Restores the frame back to its size and position prior to a <code>maximizeFrame</code> call.
   *
   * @param f the <code>JInternalFrame</code> to be restored
   */
  public void minimizeFrame(JInternalFrame f) {
    // If the frame was an icon restore it back to an icon.
    if (f.isIcon()) {
      iconifyFrame(f);
      return;
    }

    if ((f.getNormalBounds()) != null) {
      Rectangle r = f.getNormalBounds();
      f.setNormalBounds(null);
      try {
        f.setSelected(true);
      } catch (PropertyVetoException e2) {
      }
      setBoundsForFrame(f, r.x, r.y, r.width, r.height);
    }
  }
コード例 #4
0
  /**
   * Resizes the frame to fill its parents bounds.
   *
   * @param f the frame to be resized
   */
  public void maximizeFrame(JInternalFrame f) {
    if (f.isIcon()) {
      try {
        // In turn calls deiconifyFrame in the desktop manager.
        // That method will handle the maximization of the frame.
        f.setIcon(false);
      } catch (PropertyVetoException e2) {
      }
    } else {
      f.setNormalBounds(f.getBounds());
      Rectangle desktopBounds = f.getParent().getBounds();
      setBoundsForFrame(f, 0, 0, desktopBounds.width, desktopBounds.height);
    }

    // Set the maximized frame as selected.
    try {
      f.setSelected(true);
    } catch (PropertyVetoException e2) {
    }
  }
コード例 #5
0
  /**
   * Removes the frame from its parent and adds its <code>desktopIcon</code> to the parent.
   *
   * @param f the <code>JInternalFrame</code> to be iconified
   */
  public void iconifyFrame(JInternalFrame f) {
    JInternalFrame.JDesktopIcon desktopIcon;
    Container c = f.getParent();
    JDesktopPane d = f.getDesktopPane();
    boolean findNext = f.isSelected();
    desktopIcon = f.getDesktopIcon();
    if (!wasIcon(f)) {
      Rectangle r = getBoundsForIconOf(f);
      desktopIcon.setBounds(r.x, r.y, r.width, r.height);
      setWasIcon(f, Boolean.TRUE);
    }

    if (c == null || d == null) {
      return;
    }

    if (c instanceof JLayeredPane) {
      JLayeredPane lp = (JLayeredPane) c;
      int layer = lp.getLayer(f);
      lp.putLayer(desktopIcon, layer);
    }

    // If we are maximized we already have the normal bounds recorded
    // don't try to re-record them, otherwise we incorrectly set the
    // normal bounds to maximized state.
    if (!f.isMaximum()) {
      f.setNormalBounds(f.getBounds());
    }
    d.setComponentOrderCheckingEnabled(false);
    c.remove(f);
    c.add(desktopIcon);
    d.setComponentOrderCheckingEnabled(true);
    c.repaint(f.getX(), f.getY(), f.getWidth(), f.getHeight());
    if (findNext) {
      if (d.selectFrame(true) == null) {
        // The icon is the last frame.
        f.restoreSubcomponentFocus();
      }
    }
  }
コード例 #6
0
 /**
  * Stores the bounds of the component just before a maximize call.
  *
  * @param f the component about to be resized
  * @param r the normal bounds to be saved away
  */
 protected void setPreviousBounds(JInternalFrame f, Rectangle r) {
   f.setNormalBounds(r);
 }