/**
  * 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();
   }
 }
  /**
   * 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();
      }
    }
  }
示例#3
0
  private void saveSettings() {
    if (localSettings != null) {
      localSettings.objectDirectory = levelHolder.getPalette().getDirectoryPath();

      localSettings.mainWidth = this.getWidth();
      localSettings.mainHeight = this.getHeight();

      localSettings.paletteX = palette.getX();
      localSettings.paletteY = palette.getY();
      localSettings.paletteWidth = palette.getWidth();
      localSettings.paletteHeight = palette.getHeight();

      localSettings.levelHolderX = levelHolderFrame.getX();
      localSettings.levelHolderY = levelHolderFrame.getY();
      localSettings.levelHolderWidth = levelHolderFrame.getWidth();
      localSettings.levelHolderHeight = levelHolderFrame.getHeight();

      localSettings.store();
    } else {
      localSettings = new LocalSettings();
    }
  }