Java Code Examples for javax.swing.JInternalFrame#getDesktopPane()

The following examples show how to use javax.swing.JInternalFrame#getDesktopPane() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OOODesktopManager.java    From noa-libre with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void activateFrame(JInternalFrame f) {
  Container p = f.getParent();
  Component[] c;
  JDesktopPane d = f.getDesktopPane();
  JInternalFrame currentlyActiveFrame = (d == null) ? null : d.getSelectedFrame();
  // fix for bug: 4162443
  if (p == null) {
    // If the frame is not in parent, its icon maybe, check it
    p = f.getDesktopIcon().getParent();
    if (p == null)
      return;
  }
  // we only need to keep track of the currentActive InternalFrame, if any
  if (currentlyActiveFrame == null) {
    if (d != null) {
      d.setSelectedFrame(f);
    }
  }
  else if (currentlyActiveFrame != f) {
    // if not the same frame as the current active
    // we deactivate the current 
    if (currentlyActiveFrame.isSelected()) {
      try {
        currentlyActiveFrame.setSelected(false);
      }
      catch (Exception e2) {
      }
    }
    if (d != null) {
      d.setSelectedFrame(f);
    }
  }
  f.moveToFront();
}
 
Example 2
Source File: OOODesktopManager.java    From noa-libre with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
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) {
    return;
  }

  if (c instanceof JLayeredPane) {
    JLayeredPane lp = (JLayeredPane) c;
    int layer = JLayeredPane.getLayer(f);
    JLayeredPane.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());
  }
  //c.remove(f); XXX
  oldBounds.put(f, f.getBounds()); //XXX
  f.setBounds(0, 0, 0, 0); //XXX

  c.add(desktopIcon);
  c.repaint(f.getX(), f.getY(), f.getWidth(), f.getHeight());
  try {
    f.setSelected(false);
  }
  catch (PropertyVetoException e2) {
  }

  // Get topmost of the remaining frames
  if (findNext) {
    activateNextFrame(c);
  }
}