Package javax.swing.plaf.synth

Examples of javax.swing.plaf.synth.SynthStyle


        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);
View Full Code Here


        }
        final SynthStyleFactory original = SynthLookAndFeel.getStyleFactory();
        SynthLookAndFeel.setStyleFactory(new SynthStyleFactory() {
            @Override
            public SynthStyle getStyle(final JComponent c, final Region id) {
                final SynthStyle style = original.getStyle(c, id);
                if (id == Region.POPUP_MENU) {
                    fixPopupMenuStyle(style);
                } else if (id == Region.POPUP_MENU_SEPARATOR) {
                    fixPopupMenuSeparatorStyle(style);
                }
                return style;
            }

            private void fixPopupMenuStyle(SynthStyle style) {
                try {
                    Field f = getAccessibleFieldFromStyle(style, "xThickness");
                    final Object x = f.get(style);
                    if (x instanceof Integer && (Integer)x == 0) {
                        f.set(style, 1);
                        f = getAccessibleFieldFromStyle(style, "yThickness");
                        f.set(style, 3);
                    }
                } catch (Exception ignore) {
                    // ignore
                }
            }

            private void fixPopupMenuSeparatorStyle(SynthStyle style) {
                try {
                    Field f = getAccessibleFieldFromStyle(style, "yThickness");
                    final Object y = f.get(style);
                    if (y instanceof Integer && (Integer)y == 0) {
                        f.set(style, 2);
                    }
                } catch (Exception ignore) {
                    // ignore
                }
            }

            private Field getAccessibleFieldFromStyle(SynthStyle style, String fieldName) throws NoSuchFieldException {
                Field f = style.getClass().getDeclaredField(fieldName);
                f.setAccessible(true);
                return f;
            }
        });
View Full Code Here

TOP

Related Classes of javax.swing.plaf.synth.SynthStyle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.