Search in sources :

Example 1 with SynthStyleFactory

use of javax.swing.plaf.synth.SynthStyleFactory in project intellij-community by JetBrains.

the class LafManagerImpl method fixGtkPopupStyle.

private static void fixGtkPopupStyle() {
    if (!UIUtil.isUnderGTKLookAndFeel())
        return;
    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) {
                final Integer x = ReflectionUtil.getField(style.getClass(), style, int.class, "xThickness");
                if (x != null && x == 0) {
                    // workaround for Sun bug #6636964
                    ReflectionUtil.setField(style.getClass(), style, int.class, "xThickness", 1);
                    ReflectionUtil.setField(style.getClass(), style, int.class, "yThickness", 3);
                }
            }
            return style;
        }
    });
    // invokes updateUI() -> updateStyle()
    new JBPopupMenu();
    SynthLookAndFeel.setStyleFactory(original);
}
Also used : Region(javax.swing.plaf.synth.Region) SynthStyle(javax.swing.plaf.synth.SynthStyle) SynthStyleFactory(javax.swing.plaf.synth.SynthStyleFactory) JBPopupMenu(com.intellij.openapi.ui.JBPopupMenu)

Example 2 with SynthStyleFactory

use of javax.swing.plaf.synth.SynthStyleFactory in project jdk8u_jdk by JetBrains.

the class NimbusLookAndFeel method initialize.

/** 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);
        }
    });
}
Also used : JComponent(javax.swing.JComponent) Region(javax.swing.plaf.synth.Region) SynthStyle(javax.swing.plaf.synth.SynthStyle) SynthStyleFactory(javax.swing.plaf.synth.SynthStyleFactory)

Aggregations

Region (javax.swing.plaf.synth.Region)2 SynthStyle (javax.swing.plaf.synth.SynthStyle)2 SynthStyleFactory (javax.swing.plaf.synth.SynthStyleFactory)2 JBPopupMenu (com.intellij.openapi.ui.JBPopupMenu)1 JComponent (javax.swing.JComponent)1