javax.swing.plaf.synth.Region#isSubregion ( )源码实例Demo

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

源代码1 项目: 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;
}
 
源代码2 项目: 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;
}
 
源代码3 项目: 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;
}
 
源代码4 项目: 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;
}