javax.swing.JInternalFrame#JDesktopIcon ( )源码实例Demo

下面列出了javax.swing.JInternalFrame#JDesktopIcon ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: seaglass   文件: SeaGlassDesktopPaneUI.java
protected void uninstallDefaults() {
    SeaGlassContext context = getContext(desktop, ENABLED);

    style.uninstallDefaults(context);
    context.dispose();
    style = null;

    if (taskBar != null) {
        for (Component comp : taskBar.getComponents()) {
            JInternalFrame.JDesktopIcon desktopIcon = (JInternalFrame.JDesktopIcon) comp;
            taskBar.remove(desktopIcon);
            desktopIcon.setPreferredSize(null);
            JInternalFrame f = desktopIcon.getInternalFrame();
            if (f.isIcon()) {
                desktop.add(desktopIcon);
            }
            f.removeComponentListener(taskBar);
        }
        desktop.remove(taskBar);
        taskBar = null;
    }
}
 
源代码2 项目: seaglass   文件: SeaGlassDesktopPaneUI.java
public void componentAdded(ContainerEvent e) {
    if (e.getChild() instanceof JInternalFrame) {
        JInternalFrame f = (JInternalFrame) e.getChild();
        JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon();
        for (Component comp : getComponents()) {
            if (comp == desktopIcon) {
                // We have it already
                return;
            }
        }
        add(desktopIcon);
        f.addComponentListener(this);
        if (getComponentCount() == 1) {
            adjustSize();
        }
    }
}
 
源代码3 项目: seaglass   文件: SeaGlassDesktopPaneUI.java
public void deiconifyFrame(JInternalFrame f) {
    JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon();
    Container c = desktopIcon.getParent();
    if (c != null) {
        c = c.getParent();
        if (c != null) {
            c.add(f);
            if (f.isMaximum()) {
                int w = c.getWidth();
                int h = c.getHeight() - taskBar.getHeight();
                if (f.getWidth() != w || f.getHeight() != h) {
                    setBoundsForFrame(f, 0, 0, w, h);
                }
            }
            if (f.isSelected()) {
                f.moveToFront();
            } else {
                try {
                    f.setSelected(true);
                } catch (PropertyVetoException e2) {
                }
            }
        }
    }
}
 
源代码4 项目: seaglass   文件: SeaGlassDesktopIconUI.java
public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getSource() instanceof JInternalFrame.JDesktopIcon) {
        if (SeaGlassLookAndFeel.shouldUpdateStyle(evt)) {
            updateStyle((JInternalFrame.JDesktopIcon) evt.getSource());
        }
    } else if (evt.getSource() instanceof JInternalFrame) {
        JInternalFrame frame = (JInternalFrame) evt.getSource();
        if (iconPane instanceof JToggleButton) {
            JToggleButton button = (JToggleButton) iconPane;
            String prop = evt.getPropertyName();
            if (prop == "title") {
                button.setText((String) evt.getNewValue());
            } else if (prop == "frameIcon") {
                button.setIcon((Icon) evt.getNewValue());
            } else if (prop == JInternalFrame.IS_ICON_PROPERTY || prop == JInternalFrame.IS_SELECTED_PROPERTY) {
                button.setSelected(!frame.isIcon() && frame.isSelected());
            }
        }
    }
}
 
源代码5 项目: jdk1.8-source-analysis   文件: NimbusDefaults.java
private boolean matches(Component c, int partIndex) {
    if (partIndex < 0) return true;
    if (c == null) return false;
    //only get here if partIndex > 0 and c == null

    String name = c.getName();
    if (parts[partIndex].named && parts[partIndex].s.equals(name)) {
        //so far so good, recurse
        return matches(c.getParent(), partIndex - 1);
    } else if (!parts[partIndex].named) {
        //if c is not named, and parts[partIndex] has an expected class
        //type registered, then check to make sure c is of the
        //right type;
        Class clazz = parts[partIndex].c;
        if (clazz != null && clazz.isAssignableFrom(c.getClass())) {
            //so far so good, recurse
            return matches(c.getParent(), partIndex - 1);
        } else if (clazz == null &&
                   registeredRegions.containsKey(parts[partIndex].s)) {
            Region r = registeredRegions.get(parts[partIndex].s);
            Component parent = r.isSubregion() ? c : c.getParent();
            //special case the JInternalFrameTitlePane, because it
            //doesn't fit the mold. very, very funky.
            if (r == Region.INTERNAL_FRAME_TITLE_PANE && parent != null
                && parent instanceof JInternalFrame.JDesktopIcon) {
                JInternalFrame.JDesktopIcon icon =
                        (JInternalFrame.JDesktopIcon) parent;
                parent = icon.getInternalFrame();
            }
            //it was the name of a region. So far, so good. Recurse.
            return matches(parent, partIndex - 1);
        }
    }

    return false;
}
 
源代码6 项目: JDKSourceCode1.8   文件: NimbusDefaults.java
private boolean matches(Component c, int partIndex) {
    if (partIndex < 0) return true;
    if (c == null) return false;
    //only get here if partIndex > 0 and c == null

    String name = c.getName();
    if (parts[partIndex].named && parts[partIndex].s.equals(name)) {
        //so far so good, recurse
        return matches(c.getParent(), partIndex - 1);
    } else if (!parts[partIndex].named) {
        //if c is not named, and parts[partIndex] has an expected class
        //type registered, then check to make sure c is of the
        //right type;
        Class clazz = parts[partIndex].c;
        if (clazz != null && clazz.isAssignableFrom(c.getClass())) {
            //so far so good, recurse
            return matches(c.getParent(), partIndex - 1);
        } else if (clazz == null &&
                   registeredRegions.containsKey(parts[partIndex].s)) {
            Region r = registeredRegions.get(parts[partIndex].s);
            Component parent = r.isSubregion() ? c : c.getParent();
            //special case the JInternalFrameTitlePane, because it
            //doesn't fit the mold. very, very funky.
            if (r == Region.INTERNAL_FRAME_TITLE_PANE && parent != null
                && parent instanceof JInternalFrame.JDesktopIcon) {
                JInternalFrame.JDesktopIcon icon =
                        (JInternalFrame.JDesktopIcon) parent;
                parent = icon.getInternalFrame();
            }
            //it was the name of a region. So far, so good. Recurse.
            return matches(parent, partIndex - 1);
        }
    }

    return false;
}
 
源代码7 项目: freecol   文件: Canvas.java
/**
 * Get any panel this {@code Canvas} is displaying.
 *
 * @return A {@code Component} the {@code Canvas} is
 *         displaying, or null if none found.
 */
public Component getShowingSubPanel() {
    for (Component c : getComponents()) {
        if (c instanceof ToolBoxFrame) {
            continue;
        }
        if (c instanceof JInternalFrame) {
            return c;
        } else if (c instanceof JInternalFrame.JDesktopIcon) {
            return c;
        }
    }
    return null;
}
 
源代码8 项目: openjdk-jdk9   文件: 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;
    }
}
 
源代码9 项目: openjdk-jdk9   文件: 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()));
    }
}
 
源代码10 项目: openjdk-jdk9   文件: 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"));
    }
}
 
源代码11 项目: Java8CN   文件: NimbusDefaults.java
private boolean matches(Component c, int partIndex) {
    if (partIndex < 0) return true;
    if (c == null) return false;
    //only get here if partIndex > 0 and c == null

    String name = c.getName();
    if (parts[partIndex].named && parts[partIndex].s.equals(name)) {
        //so far so good, recurse
        return matches(c.getParent(), partIndex - 1);
    } else if (!parts[partIndex].named) {
        //if c is not named, and parts[partIndex] has an expected class
        //type registered, then check to make sure c is of the
        //right type;
        Class clazz = parts[partIndex].c;
        if (clazz != null && clazz.isAssignableFrom(c.getClass())) {
            //so far so good, recurse
            return matches(c.getParent(), partIndex - 1);
        } else if (clazz == null &&
                   registeredRegions.containsKey(parts[partIndex].s)) {
            Region r = registeredRegions.get(parts[partIndex].s);
            Component parent = r.isSubregion() ? c : c.getParent();
            //special case the JInternalFrameTitlePane, because it
            //doesn't fit the mold. very, very funky.
            if (r == Region.INTERNAL_FRAME_TITLE_PANE && parent != null
                && parent instanceof JInternalFrame.JDesktopIcon) {
                JInternalFrame.JDesktopIcon icon =
                        (JInternalFrame.JDesktopIcon) parent;
                parent = icon.getInternalFrame();
            }
            //it was the name of a region. So far, so good. Recurse.
            return matches(parent, partIndex - 1);
        }
    }

    return false;
}
 
源代码12 项目: noa-libre   文件: OOODesktopManager.java
public void deiconifyFrame(JInternalFrame f) {
  JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon();
  Container c = desktopIcon.getParent();
  if (c != null) {
    f.setBounds(oldBounds.remove(f)); //XXX
    //c.add(f); //XXX

    // If the frame is to be restored to a maximized state make
    // sure it still fills the whole desktop.
    if (f.isMaximum()) {
      Rectangle desktopBounds = c.getBounds();
      if (f.getWidth() != desktopBounds.width || f.getHeight() != desktopBounds.height) {
        setBoundsForFrame(f, 0, 0, desktopBounds.width, desktopBounds.height);
      }
    }
    removeIconFor(f);
    if (f.isSelected()) {
      f.moveToFront();
    }
    else {
      try {
        f.setSelected(true);
      }
      catch (PropertyVetoException e2) {
      }
    }
  }
}
 
源代码13 项目: seaglass   文件: SeaGlassDesktopPaneUI.java
protected void installDefaults() {
    updateStyle(desktop);

    if (UIManager.getBoolean("InternalFrame.useTaskBar")) {
        taskBar = new TaskBar();

        for (Component comp : desktop.getComponents()) {
            JInternalFrame.JDesktopIcon desktopIcon;

            if (comp instanceof JInternalFrame.JDesktopIcon) {
                desktopIcon = (JInternalFrame.JDesktopIcon) comp;
            } else if (comp instanceof JInternalFrame) {
                desktopIcon = ((JInternalFrame) comp).getDesktopIcon();
            } else {
                continue;
            }
            // Move desktopIcon from desktop to taskBar
            if (desktopIcon.getParent() == desktop) {
                desktop.remove(desktopIcon);
            }
            if (desktopIcon.getParent() != taskBar) {
                taskBar.add(desktopIcon);
                desktopIcon.getInternalFrame().addComponentListener(taskBar);
            }
        }
        taskBar.setBackground(desktop.getBackground());
        desktop.add(taskBar, new Integer(JLayeredPane.PALETTE_LAYER.intValue() + 1));
        if (desktop.isShowing()) {
            taskBar.adjustSize();
        }
    }
}
 
源代码14 项目: seaglass   文件: SeaGlassInternalFrameTitlePane.java
/**
 * Uninstall the defaults.
 */
public void uninstallDefaults() {
    SeaGlassContext context = getContext(this, ENABLED);

    style.uninstallDefaults(context);
    context.dispose();
    style = null;
    JInternalFrame.JDesktopIcon di = frame.getDesktopIcon();

    if (di != null && di.getComponentPopupMenu() == systemPopupMenu) {

        // Release link to systemMenu from the JInternalFrame
        di.setComponentPopupMenu(null);
    }
}
 
源代码15 项目: openjdk-jdk9   文件: JInternalFrameOperator.java
/**
 * Constructs JDesktopIconOperator.
 *
 * @param b a component
 */
public JDesktopIconOperator(JInternalFrame.JDesktopIcon b) {
    super(b);
    setOutput(JemmyProperties.getCurrentOutput());
    setTimeouts(JemmyProperties.getCurrentTimeouts());
}
 
源代码16 项目: openjdk-jdk9   文件: JInternalFrameOperator.java
@Override
public boolean checkComponent(Component comp) {
    return ((comp instanceof JInternalFrame || comp instanceof JInternalFrame.JDesktopIcon)
            && sf.checkComponent(comp));
}
 
源代码17 项目: noa-libre   文件: OOODesktopManager.java
@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);
  }
}
 
源代码18 项目: seaglass   文件: SeaGlassLookAndFeel.java
/**
 * Internal method to determine whether a component matches a part of a
 * style. Recurses to do the work.
 *
 * @param  c         the component to test against the current style
 *                   hierarchy.
 * @param  partIndex the index of the part of the hierarchy.
 *
 * @return {@code true} if the component matches the style,
 *         {@code false} otherwise.
 */
private boolean matches(Component c, int partIndex) {
    if (partIndex < 0)
        return true;

    if (c == null)
        return false;
            // only get here if partIndex > 0 and c == null

    String name = c.getName();

    if (parts[partIndex].named && parts[partIndex].s.equals(name)) {

        // so far so good, recurse
        return matches(c.getParent(), partIndex - 1);
    } else if (!parts[partIndex].named) {

        // If c is not named, and parts[partIndex] has an expected class
        // type registered, then check to make sure c is of the right
        // type;
        Class clazz = parts[partIndex].c;

        if (clazz != null && clazz.isAssignableFrom(c.getClass())) {

            // so far so good, recurse
            return matches(c.getParent(), partIndex - 1);
        } else if (clazz == null && registeredRegions.containsKey(parts[partIndex].s)) {
            Region    r      = registeredRegions.get(parts[partIndex].s);
            Component parent = r.isSubregion() ? c : c.getParent();

            // special case the JInternalFrameTitlePane, because it
            // doesn't fit the mold. very, very funky.
            if (r == Region.INTERNAL_FRAME_TITLE_PANE && parent != null && parent instanceof JInternalFrame.JDesktopIcon) {
                JInternalFrame.JDesktopIcon icon = (JInternalFrame.JDesktopIcon) parent;

                parent = icon.getInternalFrame();
            } else if (r == Region.INTERNAL_FRAME_TITLE_PANE && c instanceof SeaGlassTitlePane) {

                // Also special case the title pane. Its parent is the
                // layered pane and hasn't yet been assigned, but we
                // want it to behave as if its parent is an internal
                // frame.
                if (partIndex <= 0
                        || (parts[partIndex - 1].c != null && parts[partIndex - 1].c.isAssignableFrom(JInternalFrame.class))) {
                    return true;
                }
            }

            // it was the name of a region. So far, so good. Recurse.
            return matches(parent, partIndex - 1);
        }
    }

    return false;
}