javax.swing.plaf.synth.Region Java Examples

The following examples show how to use javax.swing.plaf.synth.Region. 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: SeaGlassScrollBarUI.java    From seaglass with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #2
Source File: ColorCustomizationTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #3
Source File: ColorCustomizationTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: ColorCustomizationTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: ColorCustomizationTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #6
Source File: ColorCustomizationTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #7
Source File: ColorCustomizationTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #8
Source File: SeaGlassTreeUI.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * @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);
    }
}
 
Example #9
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
            }
        });
}
 
Example #10
Source File: SeaGlassTextFieldUI.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #11
Source File: SeaGlassScrollBarUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
protected void paint(SeaGlassContext context, Graphics g) {
    SeaGlassContext subcontext = getContext(scrollbar, Region.SCROLL_BAR_TRACK);
    paintTrack(subcontext, g, getTrackBounds());
    subcontext.dispose();

    if (buttonsTogether.isInState(context.getComponent())) {
        subcontext = getContext(scrollbar, SeaGlassRegion.SCROLL_BAR_CAP);
        paintCap(subcontext, g, getCapBounds());
        subcontext.dispose();
    }

    subcontext = getContext(scrollbar, Region.SCROLL_BAR_THUMB);
    paintThumb(subcontext, g, getThumbBounds());
    subcontext.dispose();
}
 
Example #12
Source File: Test6660049.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    };
}
 
Example #13
Source File: NimbusLookAndFeel.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/** 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);
        }
    });
}
 
Example #14
Source File: Test6660049.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    };
}
 
Example #15
Source File: NimbusLookAndFeel.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/** 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);
        }
    });
}
 
Example #16
Source File: SeaGlassSplitPaneUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
private int getComponentState(JComponent c, Region subregion) {
    int state = SeaGlassLookAndFeel.getComponentState(c);

    if (divider.isMouseOver()) {
        state |= MOUSE_OVER;
    }
    return state;
}
 
Example #17
Source File: NimbusLookAndFeel.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** 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);
        }
    });
}
 
Example #18
Source File: Test6660049.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    };
}
 
Example #19
Source File: Test6660049.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    };
}
 
Example #20
Source File: Test6660049.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    };
}
 
Example #21
Source File: ThemeValue.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** 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);
}
 
Example #22
Source File: ThemeValue.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** 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);
}
 
Example #23
Source File: NimbusLookAndFeel.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/** 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);
        }
    });
}
 
Example #24
Source File: Test6660049.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    };
}
 
Example #25
Source File: SeaGlassMenuUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * @inheritDoc
 */
@Override
protected void uninstallDefaults() {
    SeaGlassContext context = getContext(menuItem, ENABLED);
    style.uninstallDefaults(context);
    context.dispose();
    style = null;

    SeaGlassContext accContext = getContext(menuItem, Region.MENU_ITEM_ACCELERATOR, ENABLED);
    accStyle.uninstallDefaults(accContext);
    accContext.dispose();
    accStyle = null;

    super.uninstallDefaults();
}
 
Example #26
Source File: SeaGlassToolBarUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #27
Source File: NimbusLookAndFeel.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/** 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);
        }
    });
}
 
Example #28
Source File: Test6660049.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    };
}
 
Example #29
Source File: bug8081411.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void testSynthIcon() {

        if (!checkAndSetNimbusLookAndFeel()) {
            return;
        }

        JMenuItem menu = new JMenuItem();
        Icon subMenuIcon = UIManager.getIcon("Menu.arrowIcon");

        if (!(subMenuIcon instanceof SynthIcon)) {
            throw new RuntimeException("Icon is not a SynthIcon!");
        }

        Region region = SynthLookAndFeel.getRegion(menu);
        SynthStyle style = SynthLookAndFeel.getStyle(menu, region);
        SynthContext synthContext = new SynthContext(menu, region, style, SynthConstants.ENABLED);

        int width = SynthGraphicsUtils.getIconWidth(subMenuIcon, synthContext);
        int height = SynthGraphicsUtils.getIconHeight(subMenuIcon, synthContext);
        paintAndCheckIcon(subMenuIcon, synthContext, width, height);

        int newWidth = width * 17;
        int newHeight = height * 37;
        Icon centeredIcon = new CenteredSynthIcon((SynthIcon) subMenuIcon,
                newWidth, newHeight);
        paintAndCheckIcon(centeredIcon, synthContext, newWidth, newHeight);
    }
 
Example #30
Source File: SeaGlassToolBarUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
@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();
}