类javax.swing.plaf.synth.Region源码实例Demo

下面列出了怎么用javax.swing.plaf.synth.Region的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dragonwell8_jdk   文件: ColorCustomizationTest.java
void testNames() {
    Color defaultColor = label.getBackground();

    UIManager.put("\"BlueLabel\"[Enabled].background",
            new ColorUIResource(Color.BLUE));
    UIManager.put("\"RedLabel\"[Enabled].background",
            new ColorUIResource(Color.RED));
    nimbus.register(Region.LABEL, "\"BlueLabel\"");
    nimbus.register(Region.LABEL, "\"RedLabel\"");

    label.setName("BlueLabel");
    check(Color.BLUE);
    label.setName("RedLabel");
    check(Color.RED);

    // remove name, color goes back to default
    label.setName(null);
    check(defaultColor);
}
 
源代码2 项目: TencentKona-8   文件: ColorCustomizationTest.java
void testNames() {
    Color defaultColor = label.getBackground();

    UIManager.put("\"BlueLabel\"[Enabled].background",
            new ColorUIResource(Color.BLUE));
    UIManager.put("\"RedLabel\"[Enabled].background",
            new ColorUIResource(Color.RED));
    nimbus.register(Region.LABEL, "\"BlueLabel\"");
    nimbus.register(Region.LABEL, "\"RedLabel\"");

    label.setName("BlueLabel");
    check(Color.BLUE);
    label.setName("RedLabel");
    check(Color.RED);

    // remove name, color goes back to default
    label.setName(null);
    check(defaultColor);
}
 
源代码3 项目: jdk8u-dev-jdk   文件: ColorCustomizationTest.java
void testNames() {
    Color defaultColor = label.getBackground();

    UIManager.put("\"BlueLabel\"[Enabled].background",
            new ColorUIResource(Color.BLUE));
    UIManager.put("\"RedLabel\"[Enabled].background",
            new ColorUIResource(Color.RED));
    nimbus.register(Region.LABEL, "\"BlueLabel\"");
    nimbus.register(Region.LABEL, "\"RedLabel\"");

    label.setName("BlueLabel");
    check(Color.BLUE);
    label.setName("RedLabel");
    check(Color.RED);

    // remove name, color goes back to default
    label.setName(null);
    check(defaultColor);
}
 
源代码4 项目: jdk8u60   文件: ColorCustomizationTest.java
void testNames() {
    Color defaultColor = label.getBackground();

    UIManager.put("\"BlueLabel\"[Enabled].background",
            new ColorUIResource(Color.BLUE));
    UIManager.put("\"RedLabel\"[Enabled].background",
            new ColorUIResource(Color.RED));
    nimbus.register(Region.LABEL, "\"BlueLabel\"");
    nimbus.register(Region.LABEL, "\"RedLabel\"");

    label.setName("BlueLabel");
    check(Color.BLUE);
    label.setName("RedLabel");
    check(Color.RED);

    // remove name, color goes back to default
    label.setName(null);
    check(defaultColor);
}
 
源代码5 项目: seaglass   文件: SeaGlassTreeUI.java
/**
 * @inheritDoc
 */
@Override
protected void uninstallDefaults() {
    SeaGlassContext context = getContext(tree, ENABLED);

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

    context = getContext(tree, Region.TREE_CELL, ENABLED);
    cellStyle.uninstallDefaults(context);
    context.dispose();
    cellStyle = null;

    if (tree.getTransferHandler() instanceof UIResource) {
        tree.setTransferHandler(null);
    }
}
 
源代码6 项目: openjdk-jdk8u   文件: ColorCustomizationTest.java
void testNames() {
    Color defaultColor = label.getBackground();

    UIManager.put("\"BlueLabel\"[Enabled].background",
            new ColorUIResource(Color.BLUE));
    UIManager.put("\"RedLabel\"[Enabled].background",
            new ColorUIResource(Color.RED));
    nimbus.register(Region.LABEL, "\"BlueLabel\"");
    nimbus.register(Region.LABEL, "\"RedLabel\"");

    label.setName("BlueLabel");
    check(Color.BLUE);
    label.setName("RedLabel");
    check(Color.RED);

    // remove name, color goes back to default
    label.setName(null);
    check(defaultColor);
}
 
源代码7 项目: seaglass   文件: SeaGlassTextFieldUI.java
/**
 * DOCUMENT ME!
 *
 * @param g      DOCUMENT ME!
 * @param c      DOCUMENT ME!
 * @param region DOCUMENT ME!
 */
protected void paintSearchButton(Graphics g, JTextComponent c, Region region) {
    Rectangle bounds;

    if (region == SeaGlassRegion.SEARCH_FIELD_FIND_BUTTON) {
        bounds = getFindButtonBounds();
    } else {
        bounds = getCancelButtonBounds();
    }

    SeaGlassContext subcontext = getContext(c, region);

    SeaGlassLookAndFeel.updateSubregion(subcontext, g, bounds);

    SeaGlassSynthPainterImpl painter = (SeaGlassSynthPainterImpl) subcontext.getPainter();

    painter.paintSearchButtonForeground(subcontext, g, bounds.x, bounds.y, bounds.width, bounds.height);

    subcontext.dispose();
}
 
源代码8 项目: seaglass   文件: SeaGlassLookAndFeel.java
/**
 * Called by UIManager when this look and feel is installed.
 */
@Override
public void initialize() {
    super.initialize();

    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
            @Override
            public SynthStyle getStyle(JComponent c, Region r) {
                SynthStyle style = getSeaGlassStyle(c, r);

                if (!(style instanceof SeaGlassStyle)) {
                    style = new SeaGlassStyleWrapper(style);
                }

                return style;
            }
        });
}
 
源代码9 项目: jdk8u-jdk   文件: ColorCustomizationTest.java
void testNames() {
    Color defaultColor = label.getBackground();

    UIManager.put("\"BlueLabel\"[Enabled].background",
            new ColorUIResource(Color.BLUE));
    UIManager.put("\"RedLabel\"[Enabled].background",
            new ColorUIResource(Color.RED));
    nimbus.register(Region.LABEL, "\"BlueLabel\"");
    nimbus.register(Region.LABEL, "\"RedLabel\"");

    label.setName("BlueLabel");
    check(Color.BLUE);
    label.setName("RedLabel");
    check(Color.RED);

    // remove name, color goes back to default
    label.setName(null);
    check(defaultColor);
}
 
源代码10 项目: seaglass   文件: SeaGlassScrollBarUI.java
protected void uninstallDefaults() {
    SeaGlassContext context = getContext(scrollbar, ENABLED);
    style.uninstallDefaults(context);
    context.dispose();
    style = null;

    context = getContext(scrollbar, Region.SCROLL_BAR_TRACK, ENABLED);
    trackStyle.uninstallDefaults(context);
    context.dispose();
    trackStyle = null;

    context = getContext(scrollbar, Region.SCROLL_BAR_THUMB, ENABLED);
    thumbStyle.uninstallDefaults(context);
    context.dispose();
    thumbStyle = null;

    context = getContext(scrollbar, SeaGlassRegion.SCROLL_BAR_CAP, ENABLED);
    capStyle.uninstallDefaults(context);
    context.dispose();
    capStyle = null;

    super.uninstallDefaults();
}
 
源代码11 项目: jdk1.8-source-analysis   文件: NimbusLookAndFeel.java
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
 
源代码12 项目: jdk1.8-source-analysis   文件: NimbusDefaults.java
/**
 * <p>Registers the given region and prefix. The prefix, if it contains
 * quoted sections, refers to certain named components. If there are not
 * quoted sections, then the prefix refers to a generic component type.</p>
 *
 * <p>If the given region/prefix combo has already been registered, then
 * it will not be registered twice. The second registration attempt will
 * fail silently.</p>
 *
 * @param region The Synth Region that is being registered. Such as Button,
 *        or ScrollBarThumb.
 * @param prefix The UIDefault prefix. For example, could be ComboBox, or if
 *        a named components, "MyComboBox", or even something like
 *        ToolBar:"MyComboBox":"ComboBox.arrowButton"
 */
void register(Region region, String prefix) {
    //validate the method arguments
    if (region == null || prefix == null) {
        throw new IllegalArgumentException(
                "Neither Region nor Prefix may be null");
    }

    //Add a LazyStyle for this region/prefix to m.
    List<LazyStyle> styles = m.get(region);
    if (styles == null) {
        styles = new LinkedList<LazyStyle>();
        styles.add(new LazyStyle(prefix));
        m.put(region, styles);
    } else {
        //iterate over all the current styles and see if this prefix has
        //already been registered. If not, then register it.
        for (LazyStyle s : styles) {
            if (prefix.equals(s.prefix)) {
                return;
            }
        }
        styles.add(new LazyStyle(prefix));
    }

    //add this region to the map of registered regions
    registeredRegions.put(region.getName(), region);
}
 
源代码13 项目: jdk1.8-source-analysis   文件: NimbusDefaults.java
/**
 * <p>Locate the style associated with the given region, and component.
 * This is called from NimbusLookAndFeel in the SynthStyleFactory
 * implementation.</p>
 *
 * <p>Lookup occurs as follows:<br/>
 * Check the map of styles <code>m</code>. If the map contains no styles at
 * all, then simply return the defaultStyle. If the map contains styles,
 * then iterate over all of the styles for the Region <code>r</code> looking
 * for the best match, based on prefix. If a match was made, then return
 * that SynthStyle. Otherwise, return the defaultStyle.</p>
 *
 * @param comp The component associated with this region. For example, if
 *        the Region is Region.Button then the component will be a JButton.
 *        If the Region is a subregion, such as ScrollBarThumb, then the
 *        associated component will be the component that subregion belongs
 *        to, such as JScrollBar. The JComponent may be named. It may not be
 *        null.
 * @param r The region we are looking for a style for. May not be null.
 */
SynthStyle getStyle(JComponent comp, Region r) {
    //validate method arguments
    if (comp == null || r == null) {
        throw new IllegalArgumentException(
                "Neither comp nor r may be null");
    }

    //if there are no lazy styles registered for the region r, then return
    //the default style
    List<LazyStyle> styles = m.get(r);
    if (styles == null || styles.size() == 0) {
        return defaultStyle;
    }

    //Look for the best SynthStyle for this component/region pair.
    LazyStyle foundStyle = null;
    for (LazyStyle s : styles) {
        if (s.matches(comp)) {
            //replace the foundStyle if foundStyle is null, or
            //if the new style "s" is more specific (ie, its path was
            //longer), or if the foundStyle was "simple" and the new style
            //was not (ie: the foundStyle was for something like Button and
            //the new style was for something like "MyButton", hence, being
            //more specific.) In all cases, favor the most specific style
            //found.
            if (foundStyle == null ||
               (foundStyle.parts.length < s.parts.length) ||
               (foundStyle.parts.length == s.parts.length 
                && foundStyle.simple && !s.simple)) {
                foundStyle = s;
            }
        }
    }

    //return the style, if found, or the default style if not found
    return foundStyle == null ? defaultStyle : foundStyle.getStyle(comp, r);
}
 
源代码14 项目: 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;
}
 
源代码15 项目: dragonwell8_jdk   文件: NimbusLookAndFeel.java
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
 
源代码16 项目: TencentKona-8   文件: NimbusLookAndFeel.java
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
 
源代码17 项目: TencentKona-8   文件: Test6660049.java
private Test6660049(Class<? extends JComponent>... types) {
    this.types = types;
    run();

    this.region = new Region("Button", "ButtonUI", true) {
        @Override
        public String getName() {
            throw new Error("6660049: exploit is available");
        }
    };
}
 
源代码18 项目: jdk8u60   文件: NimbusLookAndFeel.java
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
 
源代码19 项目: JDKSourceCode1.8   文件: NimbusLookAndFeel.java
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
 
源代码20 项目: seaglass   文件: SeaGlassScrollBarUI.java
private SeaGlassContext getContext(JComponent c, Region region, int state) {
    SynthStyle style = trackStyle;

    if (region == Region.SCROLL_BAR_THUMB) {
        style = thumbStyle;
    } else if (region == SeaGlassRegion.SCROLL_BAR_CAP) {
        style = capStyle;
    }
    return SeaGlassContext.getContext(SeaGlassContext.class, c, region, style, state);
}
 
源代码21 项目: JDKSourceCode1.8   文件: NimbusDefaults.java
/**
 * Gets the style. Creates it if necessary.
 * @return the style
 */
SynthStyle getStyle(JComponent c, Region r) {
    // if the component has overrides, it gets its own unique style
    // instead of the shared style.
    if (c.getClientProperty("Nimbus.Overrides") != null) {
        Map<Region, SynthStyle> map = overridesCache.get(c);
        SynthStyle s = null;
        if (map == null) {
            map = new HashMap<Region, SynthStyle>();
            overridesCache.put(c, map);
        } else {
            s = map.get(r);
        }
        if (s == null) {
            s = new NimbusStyle(prefix, c);
            map.put(r, s);
        }
        return s;
    }
    
    // lazily create the style if necessary
    if (style == null)
        style = new NimbusStyle(prefix, null);
    
    // return the style
    return style;
}
 
源代码22 项目: openjdk-jdk8u   文件: NimbusLookAndFeel.java
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
 
源代码23 项目: seaglass   文件: SeaGlassSplitPaneUI.java
private int getComponentState(JComponent c, Region subregion) {
    int state = SeaGlassLookAndFeel.getComponentState(c);

    if (divider.isMouseOver()) {
        state |= MOUSE_OVER;
    }
    return state;
}
 
源代码24 项目: jdk8u-jdk   文件: Test6660049.java
private Test6660049(Class<? extends JComponent>... types) {
    this.types = types;
    run();

    this.region = new Region("Button", "ButtonUI", true) {
        @Override
        public String getName() {
            throw new Error("6660049: exploit is available");
        }
    };
}
 
源代码25 项目: netbeans   文件: ThemeValue.java
/** Creates a new instance of GTKColor */
public ThemeValue(Region region, ColorType colorType, Object fallback) {
    this.fallback = fallback;
    this.aRegion = region;
    this.aColorType = colorType;
    register(this);
}
 
源代码26 项目: netbeans   文件: ThemeValue.java
/** Creates a new instance of GTKColor */
public ThemeValue(Region region, ColorType colorType, Object fallback, boolean darken) {
    this.fallback = fallback;
    this.aRegion = region;
    this.aColorType = colorType;
    this.darken = darken;
    register(this);
}
 
源代码27 项目: jdk8u-dev-jdk   文件: Test6660049.java
private Test6660049(Class<? extends JComponent>... types) {
    this.types = types;
    run();

    this.region = new Region("Button", "ButtonUI", true) {
        @Override
        public String getName() {
            throw new Error("6660049: exploit is available");
        }
    };
}
 
源代码28 项目: seaglass   文件: SeaGlassToolBarUI.java
protected void paint(SeaGlassContext context, Graphics g) {
    if (handleIcon != null && toolBar.isFloatable()) {
        int startX = toolBar.getComponentOrientation().isLeftToRight() ? 0 : toolBar.getWidth()
                - SeaGlassIcon.getIconWidth(handleIcon, context);
        SeaGlassIcon.paintIcon(handleIcon, context, g, startX, 0, SeaGlassIcon.getIconWidth(handleIcon, context), SeaGlassIcon.getIconHeight(
            handleIcon, context));
    }

    SeaGlassContext subcontext = getContext(toolBar, Region.TOOL_BAR_CONTENT, contentStyle);
    // paintContent(subcontext, g, contentRect);
    subcontext.dispose();
}
 
源代码29 项目: openjdk-jdk8u-backup   文件: Test6660049.java
private Test6660049(Class<? extends JComponent>... types) {
    this.types = types;
    run();

    this.region = new Region("Button", "ButtonUI", true) {
        @Override
        public String getName() {
            throw new Error("6660049: exploit is available");
        }
    };
}
 
源代码30 项目: seaglass   文件: SeaGlassToolBarUI.java
@Override
protected void paintDragWindow(Graphics g) {
    int w = dragWindow.getWidth();
    int h = dragWindow.getHeight();
    SeaGlassContext context = getContext(toolBar, Region.TOOL_BAR_DRAG_WINDOW, dragWindowStyle);
    SeaGlassLookAndFeel.updateSubregion(context, g, new Rectangle(0, 0, w, h));
    context.getPainter().paintToolBarDragWindowBackground(context, g, 0, 0, w, h, dragWindow.getOrientation());
    context.getPainter().paintToolBarDragWindowBorder(context, g, 0, 0, w, h, dragWindow.getOrientation());
    context.dispose();
}
 
 类所在包
 同包方法