Java 类javax.swing.JInternalFrame.JDesktopIcon 实例源码

项目:openjdk9    文件:JInternalFrameOperator.java   
@Override
public boolean checkComponent(Component comp) {
    if (comp instanceof JInternalFrame || comp instanceof JInternalFrame.JDesktopIcon) {
        JInternalFrame frame = null;
        if (comp instanceof JInternalFrame) {
            frame = (JInternalFrame) comp;
        } else {
            JDesktopIconOperator io = new JDesktopIconOperator((JInternalFrame.JDesktopIcon) comp);
            frame = io.getInternalFrame();
        }
        if (frame.getTitle() != null) {
            return (comparator.equals(frame.getTitle(),
                    label));
        }
    }
    return false;
}
项目:javify    文件:DefaultDesktopManager.java   
/**
 * This method is called to indicate that the DesktopManager should prepare
 * to drag the JInternalFrame. Any state information needed to drag the
 * frame will be prepared now.
 *
 * @param component The JComponent to drag, usually a JInternalFrame.
 */
public void beginDraggingFrame(JComponent component)
{
  if (component instanceof JDesktopIcon)
    pane = ((JDesktopIcon) component).getInternalFrame().getDesktopPane();
  else
    pane = ((JInternalFrame) component).getDesktopPane();
  if (pane == null)
    return;

  dragCache = component.getBounds();

  if (! (pane instanceof JDesktopPane))
    currentDragMode = JDesktopPane.LIVE_DRAG_MODE;
  else
    currentDragMode = ((JDesktopPane) pane).getDragMode();
}
项目:javify    文件:DefaultDesktopManager.java   
/**
 * This method is called to drag the JInternalFrame to a new location.
 *
 * @param component The JComponent to drag, usually a JInternalFrame.
 *
 * @param newX The new x coordinate.
 * @param newY The new y coordinate.
 */
public void dragFrame(JComponent component, int newX, int newY)
{
  if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE)
    {
      // FIXME: Do outline drag mode painting.
    }
  else
    {
      Rectangle b = component.getBounds();
      if (component instanceof JDesktopIcon)
        component.setBounds(newX, newY, b.width, b.height);
      else
        setBoundsForFrame((JInternalFrame) component, newX, newY, b.width,
                          b.height);
    }
}
项目:javify    文件:BasicDesktopIconUI.java   
/**
 * This method installs the UI for the given JComponent.
 *
 * @param c The JComponent to install this UI for.
 */
public void installUI(JComponent c)
{
  if (c instanceof JDesktopIcon)
    {
      desktopIcon = (JDesktopIcon) c;
      desktopIcon.setLayout(new BorderLayout());
      frame = desktopIcon.getInternalFrame();

      installDefaults();
      installComponents();
      installListeners();

      desktopIcon.setOpaque(true);
    }
}
项目:jvm-stm    文件:DefaultDesktopManager.java   
/**
 * This method is called to indicate that the DesktopManager should prepare
 * to drag the JInternalFrame. Any state information needed to drag the
 * frame will be prepared now.
 *
 * @param component The JComponent to drag, usually a JInternalFrame.
 */
public void beginDraggingFrame(JComponent component)
{
  if (component instanceof JDesktopIcon)
    pane = ((JDesktopIcon) component).getInternalFrame().getDesktopPane();
  else
    pane = ((JInternalFrame) component).getDesktopPane();
  if (pane == null)
    return;

  dragCache = component.getBounds();

  if (! (pane instanceof JDesktopPane))
    currentDragMode = JDesktopPane.LIVE_DRAG_MODE;
  else
    currentDragMode = ((JDesktopPane) pane).getDragMode();
}
项目:jvm-stm    文件:DefaultDesktopManager.java   
/**
 * This method is called to drag the JInternalFrame to a new location.
 *
 * @param component The JComponent to drag, usually a JInternalFrame.
 *
 * @param newX The new x coordinate.
 * @param newY The new y coordinate.
 */
public void dragFrame(JComponent component, int newX, int newY)
{
  if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE)
    {
      // FIXME: Do outline drag mode painting.
    }
  else
    {
      Rectangle b = component.getBounds();
      if (component instanceof JDesktopIcon)
        component.setBounds(newX, newY, b.width, b.height);
      else
        setBoundsForFrame((JInternalFrame) component, newX, newY, b.width,
                          b.height);
    }
}
项目:jvm-stm    文件:BasicDesktopIconUI.java   
/**
  * This method installs the UI for the given JComponent.
  *
  * @param c The JComponent to install this UI for.
  */
 public void installUI(JComponent c)
 {
   if (c instanceof JDesktopIcon)
     {
desktopIcon = (JDesktopIcon) c;
desktopIcon.setLayout(new BorderLayout());
frame = desktopIcon.getInternalFrame();

installDefaults();
installComponents();
installListeners();

desktopIcon.setOpaque(true);
     }
 }
项目:seaglass    文件:TitlePaneIconifyButtonWindowMinimizedState.java   
/**
 * {@inheritDoc}
 */
public boolean isInState(JComponent c) {
    Component parent = c;

    while (parent.getParent() != null) {

        if (parent instanceof JInternalFrame || parent instanceof JDesktopIcon) {
            break;
        }

        parent = parent.getParent();
    }

    if (parent instanceof JInternalFrame) {
        return ((JInternalFrame) parent).isIcon();
    } else if (parent instanceof JDesktopIcon) {
        return true;
    }

    return false;
}
项目:JamVM-PH    文件:DefaultDesktopManager.java   
/**
 * This method is called to indicate that the DesktopManager should prepare
 * to drag the JInternalFrame. Any state information needed to drag the
 * frame will be prepared now.
 *
 * @param component The JComponent to drag, usually a JInternalFrame.
 */
public void beginDraggingFrame(JComponent component)
{
  if (component instanceof JDesktopIcon)
    pane = ((JDesktopIcon) component).getInternalFrame().getDesktopPane();
  else
    pane = ((JInternalFrame) component).getDesktopPane();
  if (pane == null)
    return;

  dragCache = component.getBounds();

  if (! (pane instanceof JDesktopPane))
    currentDragMode = JDesktopPane.LIVE_DRAG_MODE;
  else
    currentDragMode = ((JDesktopPane) pane).getDragMode();
}
项目:JamVM-PH    文件:DefaultDesktopManager.java   
/**
 * This method is called to drag the JInternalFrame to a new location.
 *
 * @param component The JComponent to drag, usually a JInternalFrame.
 *
 * @param newX The new x coordinate.
 * @param newY The new y coordinate.
 */
public void dragFrame(JComponent component, int newX, int newY)
{
  if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE)
    {
      // FIXME: Do outline drag mode painting.
    }
  else
    {
      Rectangle b = component.getBounds();
      if (component instanceof JDesktopIcon)
        component.setBounds(newX, newY, b.width, b.height);
      else
        setBoundsForFrame((JInternalFrame) component, newX, newY, b.width,
                          b.height);
    }
}
项目:JamVM-PH    文件:BasicDesktopIconUI.java   
/**
  * This method installs the UI for the given JComponent.
  *
  * @param c The JComponent to install this UI for.
  */
 public void installUI(JComponent c)
 {
   if (c instanceof JDesktopIcon)
     {
desktopIcon = (JDesktopIcon) c;
desktopIcon.setLayout(new BorderLayout());
frame = desktopIcon.getInternalFrame();

installDefaults();
installComponents();
installListeners();

desktopIcon.setOpaque(true);
     }
 }
项目:classpath    文件:DefaultDesktopManager.java   
/**
 * This method is called to indicate that the DesktopManager should prepare
 * to drag the JInternalFrame. Any state information needed to drag the
 * frame will be prepared now.
 *
 * @param component The JComponent to drag, usually a JInternalFrame.
 */
public void beginDraggingFrame(JComponent component)
{
  if (component instanceof JDesktopIcon)
    pane = ((JDesktopIcon) component).getInternalFrame().getDesktopPane();
  else
    pane = ((JInternalFrame) component).getDesktopPane();
  if (pane == null)
    return;

  dragCache = component.getBounds();

  if (! (pane instanceof JDesktopPane))
    currentDragMode = JDesktopPane.LIVE_DRAG_MODE;
  else
    currentDragMode = ((JDesktopPane) pane).getDragMode();
}
项目:classpath    文件:DefaultDesktopManager.java   
/**
 * This method is called to drag the JInternalFrame to a new location.
 *
 * @param component The JComponent to drag, usually a JInternalFrame.
 *
 * @param newX The new x coordinate.
 * @param newY The new y coordinate.
 */
public void dragFrame(JComponent component, int newX, int newY)
{
  if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE)
    {
      // FIXME: Do outline drag mode painting.
    }
  else
    {
      Rectangle b = component.getBounds();
      if (component instanceof JDesktopIcon)
        component.setBounds(newX, newY, b.width, b.height);
      else
        setBoundsForFrame((JInternalFrame) component, newX, newY, b.width,
                          b.height);
    }
}
项目:classpath    文件:BasicDesktopIconUI.java   
/**
 * This method installs the UI for the given JComponent.
 *
 * @param c The JComponent to install this UI for.
 */
public void installUI(JComponent c)
{
  if (c instanceof JDesktopIcon)
    {
      desktopIcon = (JDesktopIcon) c;
      desktopIcon.setLayout(new BorderLayout());
      frame = desktopIcon.getInternalFrame();

      installDefaults();
      installComponents();
      installListeners();

      desktopIcon.setOpaque(true);
    }
}
项目:openjdk-jdk10    文件:JInternalFrameOperator.java   
/**
 * Searches JInternalframe in container.
 *
 * @param cont Container to search component in.
 * @param chooser a component chooser specifying searching criteria.
 * @param index Ordinal component index.
 * @return JInternalframe instance or null if component was not found.
 */
public static JInternalFrame findJInternalFrame(Container cont, ComponentChooser chooser, int index) {
    Component res = findComponent(cont, new JInternalFrameFinder(chooser), index);
    if (res instanceof JInternalFrame) {
        return (JInternalFrame) res;
    } else if (res instanceof JInternalFrame.JDesktopIcon) {
        return ((JInternalFrame.JDesktopIcon) res).getInternalFrame();
    } else {
        return null;
    }
}
项目:openjdk-jdk10    文件:JInternalFrameOperator.java   
/**
 * Waits JInternalframe in container.
 *
 * @param cont Container to search component in.
 * @param chooser a component chooser specifying searching criteria.
 * @param index Ordinal component index.
 * @return JInternalframe instance.
 *
 */
public static JInternalFrame waitJInternalFrame(final Container cont, final ComponentChooser chooser, final int index) {
    Component res = waitComponent(cont, new JInternalFrameFinder(chooser), index);
    if (res instanceof JInternalFrame) {
        return (JInternalFrame) res;
    } else if (res instanceof JInternalFrame.JDesktopIcon) {
        return ((JInternalFrame.JDesktopIcon) res).getInternalFrame();
    } else {
        throw (new TimeoutExpiredException(chooser.getDescription()));
    }
}
项目:openjdk-jdk10    文件:JInternalFrameOperator.java   
/**
 * Maps {@code JInternalFrame.getDesktopIcon()} through queue
 */
public JDesktopIcon getDesktopIcon() {
    return (runMapping(new MapAction<JDesktopIcon>("getDesktopIcon") {
        @Override
        public JDesktopIcon map() {
            return ((JInternalFrame) getSource()).getDesktopIcon();
        }
    }));
}
项目:openjdk-jdk10    文件:JInternalFrameOperator.java   
/**
 * Maps {@code JInternalFrame.setDesktopIcon(JDesktopIcon)} through queue
 */
public void setDesktopIcon(final JDesktopIcon jDesktopIcon) {
    runMapping(new MapVoidAction("setDesktopIcon") {
        @Override
        public void map() {
            ((JInternalFrame) getSource()).setDesktopIcon(jDesktopIcon);
        }
    });
}
项目:openjdk-jdk10    文件:JInternalFrameOperator.java   
private static JInternalFrame findOne(ContainerOperator<?> cont, String text, int index) {
    Component source = waitComponent(cont,
            new JInternalFrameByTitleFinder(text,
                    cont.getComparator()),
            index);
    if (source instanceof JInternalFrame) {
        return (JInternalFrame) source;
    } else if (source instanceof JInternalFrame.JDesktopIcon) {
        return ((JInternalFrame.JDesktopIcon) source).getInternalFrame();
    } else {
        throw (new TimeoutExpiredException("No internal frame was found"));
    }
}
项目:openjdk9    文件:JInternalFrameOperator.java   
/**
 * Searches JInternalframe in container.
 *
 * @param cont Container to search component in.
 * @param chooser a component chooser specifying searching criteria.
 * @param index Ordinal component index.
 * @return JInternalframe instance or null if component was not found.
 */
public static JInternalFrame findJInternalFrame(Container cont, ComponentChooser chooser, int index) {
    Component res = findComponent(cont, new JInternalFrameFinder(chooser), index);
    if (res instanceof JInternalFrame) {
        return (JInternalFrame) res;
    } else if (res instanceof JInternalFrame.JDesktopIcon) {
        return ((JInternalFrame.JDesktopIcon) res).getInternalFrame();
    } else {
        return null;
    }
}
项目:openjdk9    文件:JInternalFrameOperator.java   
/**
 * Waits JInternalframe in container.
 *
 * @param cont Container to search component in.
 * @param chooser a component chooser specifying searching criteria.
 * @param index Ordinal component index.
 * @return JInternalframe instance.
 *
 */
public static JInternalFrame waitJInternalFrame(final Container cont, final ComponentChooser chooser, final int index) {
    Component res = waitComponent(cont, new JInternalFrameFinder(chooser), index);
    if (res instanceof JInternalFrame) {
        return (JInternalFrame) res;
    } else if (res instanceof JInternalFrame.JDesktopIcon) {
        return ((JInternalFrame.JDesktopIcon) res).getInternalFrame();
    } else {
        throw (new TimeoutExpiredException(chooser.getDescription()));
    }
}
项目:openjdk9    文件:JInternalFrameOperator.java   
/**
 * Maps {@code JInternalFrame.getDesktopIcon()} through queue
 */
public JDesktopIcon getDesktopIcon() {
    return (runMapping(new MapAction<JDesktopIcon>("getDesktopIcon") {
        @Override
        public JDesktopIcon map() {
            return ((JInternalFrame) getSource()).getDesktopIcon();
        }
    }));
}
项目:openjdk9    文件:JInternalFrameOperator.java   
/**
 * Maps {@code JInternalFrame.setDesktopIcon(JDesktopIcon)} through queue
 */
public void setDesktopIcon(final JDesktopIcon jDesktopIcon) {
    runMapping(new MapVoidAction("setDesktopIcon") {
        @Override
        public void map() {
            ((JInternalFrame) getSource()).setDesktopIcon(jDesktopIcon);
        }
    });
}
项目:openjdk9    文件:JInternalFrameOperator.java   
private static JInternalFrame findOne(ContainerOperator<?> cont, String text, int index) {
    Component source = waitComponent(cont,
            new JInternalFrameByTitleFinder(text,
                    cont.getComparator()),
            index);
    if (source instanceof JInternalFrame) {
        return (JInternalFrame) source;
    } else if (source instanceof JInternalFrame.JDesktopIcon) {
        return ((JInternalFrame.JDesktopIcon) source).getInternalFrame();
    } else {
        throw (new TimeoutExpiredException("No internal frame was found"));
    }
}
项目:javify    文件:DefaultDesktopManager.java   
/**
 * 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);
        }
      Rectangle b = frame.getBounds();
      c.remove(frame);
      c.repaint(b.x, b.y, b.width, b.height);
    }
}
项目:javify    文件:DefaultDesktopManager.java   
/**
 * 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();
}
项目:javify    文件:DefaultDesktopManager.java   
/**
 * This is a helper method that removes the JDesktopIcon of the given
 * JInternalFrame from the parent.
 *
 * @param frame The JInternalFrame to remove an icon for.
 */
protected void removeIconFor(JInternalFrame frame)
{
  JDesktopIcon icon = frame.getDesktopIcon();
  Container c = icon.getParent();
  if (c != null && icon != null)
    {
      Rectangle b = icon.getBounds();
      c.remove(icon);
      c.repaint(b.x, b.y, b.width, b.height);
    }
}
项目:jvm-stm    文件:DefaultDesktopManager.java   
/**
 * 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);
        }
      Rectangle b = frame.getBounds();
      c.remove(frame);
      c.repaint(b.x, b.y, b.width, b.height);
    }
}
项目:jvm-stm    文件:DefaultDesktopManager.java   
/**
 * 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();
}
项目:jvm-stm    文件:DefaultDesktopManager.java   
/**
 * This is a helper method that removes the JDesktopIcon of the given
 * JInternalFrame from the parent.
 *
 * @param frame The JInternalFrame to remove an icon for.
 */
protected void removeIconFor(JInternalFrame frame)
{
  JDesktopIcon icon = frame.getDesktopIcon();
  Container c = icon.getParent();
  if (c != null && icon != null)
    {
      Rectangle b = icon.getBounds();
      c.remove(icon);
      c.repaint(b.x, b.y, b.width, b.height);
    }
}
项目:platypus-js    文件:JScalablePanel.java   
protected JDesktopIcon iifDesktopIcon(Object aSource) {
    Component lparent = null;
    if (aSource instanceof Component) {
        lparent = (Component) aSource;
        while (lparent != null && !(lparent instanceof JDesktopIcon)) {
            lparent = lparent.getParent();
        }
        if (lparent != null) {
            return (JDesktopIcon) lparent;
        }
    }
    return null;
}
项目:JamVM-PH    文件:DefaultDesktopManager.java   
/**
 * 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);
        }
      Rectangle b = frame.getBounds();
      c.remove(frame);
      c.repaint(b.x, b.y, b.width, b.height);
    }
}
项目:JamVM-PH    文件:DefaultDesktopManager.java   
/**
 * 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();
}
项目:JamVM-PH    文件:DefaultDesktopManager.java   
/**
 * This is a helper method that removes the JDesktopIcon of the given
 * JInternalFrame from the parent.
 *
 * @param frame The JInternalFrame to remove an icon for.
 */
protected void removeIconFor(JInternalFrame frame)
{
  JDesktopIcon icon = frame.getDesktopIcon();
  Container c = icon.getParent();
  if (c != null && icon != null)
    {
      Rectangle b = icon.getBounds();
      c.remove(icon);
      c.repaint(b.x, b.y, b.width, b.height);
    }
}
项目:classpath    文件:DefaultDesktopManager.java   
/**
 * 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);
        }
      Rectangle b = frame.getBounds();
      c.remove(frame);
      c.repaint(b.x, b.y, b.width, b.height);
    }
}
项目:classpath    文件:DefaultDesktopManager.java   
/**
 * 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();
}
项目:classpath    文件:DefaultDesktopManager.java   
/**
 * This is a helper method that removes the JDesktopIcon of the given
 * JInternalFrame from the parent.
 *
 * @param frame The JInternalFrame to remove an icon for.
 */
protected void removeIconFor(JInternalFrame frame)
{
  JDesktopIcon icon = frame.getDesktopIcon();
  Container c = icon.getParent();
  if (c != null && icon != null)
    {
      Rectangle b = icon.getBounds();
      c.remove(icon);
      c.repaint(b.x, b.y, b.width, b.height);
    }
}
项目:JRLib    文件:SubstanceDesktopIconUI.java   
/**
 * Installs the UI delegate on the desktop icon if necessary.
 * 
 * @param jdi
 *            Desktop icon.
 */
public void installIfNecessary(JDesktopIcon jdi) {
    // fix for issue 344 - reopening an internal frame
    // that has been closed.
    if (this.desktopIcon == null) {
        this.installUI(jdi);
    }
}
项目:JRLib    文件:SubstanceDesktopIconUI.java   
/**
 * Uninstalls the UI delegate from the desktop icon if necessary.
 * 
 * @param jdi
 *            Desktop icon.
 */
public void uninstallIfNecessary(JDesktopIcon jdi) {
    // fix for issue 345 - an internal frame used in inner option pane
    // gets closed twice
    if (this.desktopIcon == jdi) {
        this.uninstallUI(jdi);
    }
}
项目:JRLib    文件:SubstanceInternalFrameUI.java   
@Override
protected void installListeners() {
    super.installListeners();
    this.substancePropertyListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (JInternalFrame.IS_CLOSED_PROPERTY.equals(evt
                    .getPropertyName())) {
                titlePane.uninstall();
                JDesktopIcon jdi = frame.getDesktopIcon();
                SubstanceDesktopIconUI ui = (SubstanceDesktopIconUI) jdi
                        .getUI();
                ui.uninstallIfNecessary(jdi);
            }

            if ("background".equals(evt.getPropertyName())) {
                Color newBackgr = (Color) evt.getNewValue();
                if (!(newBackgr instanceof UIResource)) {
                    getTitlePane().setBackground(newBackgr);
                    frame.getDesktopIcon().setBackground(newBackgr);
                }
            }

            if ("ancestor".equals(evt.getPropertyName())) {
                // fix for issue 344 - reopening an internal frame
                // that has been closed.
                JDesktopIcon jdi = frame.getDesktopIcon();
                SubstanceDesktopIconUI ui = (SubstanceDesktopIconUI) jdi
                        .getUI();
                ui.installIfNecessary(jdi);
            }
        }
    };
    this.frame.addPropertyChangeListener(this.substancePropertyListener);
}