Java Code Examples for javax.swing.plaf.synth.SynthLookAndFeel#getRegion()

The following examples show how to use javax.swing.plaf.synth.SynthLookAndFeel#getRegion() . 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: 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 2
Source File: SeaGlassViewportUI.java    From seaglass with Apache License 2.0 4 votes vote down vote up
private Region getRegion(JComponent c) {
    return SynthLookAndFeel.getRegion(c);
}
 
Example 3
Source File: SeaGlassButtonUI.java    From seaglass with Apache License 2.0 2 votes vote down vote up
/**
 * Get the region.
 *
 * @param  c the component.
 *
 * @return the region.
 */
private Region getRegion(JComponent c) {
    return SynthLookAndFeel.getRegion(c);
}