当前位置: 首页>>代码示例>>Java>>正文


Java SynthLookAndFeel.getStyleFactory方法代码示例

本文整理汇总了Java中javax.swing.plaf.synth.SynthLookAndFeel.getStyleFactory方法的典型用法代码示例。如果您正苦于以下问题:Java SynthLookAndFeel.getStyleFactory方法的具体用法?Java SynthLookAndFeel.getStyleFactory怎么用?Java SynthLookAndFeel.getStyleFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.plaf.synth.SynthLookAndFeel的用法示例。


在下文中一共展示了SynthLookAndFeel.getStyleFactory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fixGtkPopupStyle

import javax.swing.plaf.synth.SynthLookAndFeel; //导入方法依赖的package包/类
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;
    }
  });

  new JBPopupMenu();  // invokes updateUI() -> updateStyle()

  SynthLookAndFeel.setStyleFactory(original);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:LafManagerImpl.java

示例2: paint

import javax.swing.plaf.synth.SynthLookAndFeel; //导入方法依赖的package包/类
/** Paint bumps to specific Graphics. */
@Override
public void paint (Graphics g) {
    Icon icon = UIManager.getIcon("ToolBar.handleIcon");
    Region region = Region.TOOL_BAR;
    SynthStyleFactory sf = SynthLookAndFeel.getStyleFactory();
    SynthStyle style = sf.getStyle(toolbar, region);
    SynthContext context = new SynthContext(toolbar, region, style, SynthConstants.DEFAULT);

    SynthGraphicsUtils sgu = context.getStyle().getGraphicsUtils(context);
    sgu.paintText(context, g, null, icon, SwingConstants.LEADING, SwingConstants.LEADING, 0, 0, 0, -1, 0);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ToolbarContainer.java

示例3: fixGtkPopupStyle

import javax.swing.plaf.synth.SynthLookAndFeel; //导入方法依赖的package包/类
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) {
          try {
            Field f = style.getClass().getDeclaredField("xThickness");
            f.setAccessible(true);
            final Object x = f.get(style);
            if (x instanceof Integer && (Integer)x == 0) {
              // workaround for Sun bug #6636964
              f.set(style, 1);
              f = style.getClass().getDeclaredField("yThickness");
              f.setAccessible(true);
              f.set(style, 3);
            }
          }
          catch (Exception ignore) { }
        }
        return style;
      }
    });

  new JBPopupMenu();  // invokes updateUI() -> updateStyle()

  SynthLookAndFeel.setStyleFactory(original);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:LafManagerImpl.java

示例4: fixGtkPopupStyle

import javax.swing.plaf.synth.SynthLookAndFeel; //导入方法依赖的package包/类
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) {
        try {
          Field f = style.getClass().getDeclaredField("xThickness");
          f.setAccessible(true);
          final Object x = f.get(style);
          if (x instanceof Integer && (Integer)x == 0) {
            // workaround for Sun bug #6636964
            f.set(style, 1);
            f = style.getClass().getDeclaredField("yThickness");
            f.setAccessible(true);
            f.set(style, 3);
          }
        }
        catch (Exception ignore) {
        }
      }
      return style;
    }
  });

  new JBPopupMenu();  // invokes updateUI() -> updateStyle()

  SynthLookAndFeel.setStyleFactory(original);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:34,代码来源:LafManagerImpl.java

示例5: paintTabBackground

import javax.swing.plaf.synth.SynthLookAndFeel; //导入方法依赖的package包/类
private static void paintTabBackground (Graphics g, int index, int state,
int x, int y, int w, int h) {
    if (dummyTab == null) {
        dummyTab = new JTabbedPane();
    }
    Region region = Region.TABBED_PANE_TAB;
    if( !(UIManager.getLookAndFeel() instanceof SynthLookAndFeel) ) {
        return; //#215311 - unsupported L&F installed
    }
    SynthLookAndFeel laf = (SynthLookAndFeel) UIManager.getLookAndFeel();
    SynthStyleFactory sf = laf.getStyleFactory();
    SynthStyle style = sf.getStyle(dummyTab, region);
    SynthContext context =
        new SynthContext(dummyTab, region, style, 
            state == SynthConstants.FOCUSED ? SynthConstants.SELECTED : state);
    SynthPainter painter = style.getPainter(context);
    long t1, t2;
    if (state == SynthConstants.DEFAULT) {
        t1 = System.currentTimeMillis();
        painter.paintTabbedPaneTabBackground(context, g, x, y, w, h, index);
        t2 = System.currentTimeMillis();
        if ((t2 - t1) > 200) {
            LOG.log(Level.WARNING, "painter.paintTabbedPaneTabBackground1 takes too long"
            + " x=" + x + " y=" + y + " w=" + w + " h=" + h + " index:" + index
            + " Time=" + (t2 - t1));
        }
    } else {
        BufferedImage bufIm = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2d = bufIm.createGraphics();
        g2d.setBackground(UIManager.getColor("Panel.background"));
        g2d.clearRect(0, 0, w, h);
        t1 = System.currentTimeMillis();
        painter.paintTabbedPaneTabBackground(context, g2d, 0, 0, w, h, index);
        t2 = System.currentTimeMillis();
        if ((t2 - t1) > 200) {
            LOG.log(Level.WARNING, "painter.paintTabbedPaneTabBackground1 takes too long"
            + " x=0" + " y=0" + " w=" + w + " h=" + h + " index:" + index
            + " Time=" + (t2 - t1));
        }
        // differentiate active and selected tabs, active tab made brighter,
        // selected tab darker
        RescaleOp op = state == SynthConstants.FOCUSED 
            ? new RescaleOp(1.08f, 0, null)
            : new RescaleOp(0.96f, 0, null); 
        BufferedImage img = op.filter(bufIm, null);
        g.drawImage(img, x, y, null);
    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:50,代码来源:GtkEditorTabCellRenderer.java


注:本文中的javax.swing.plaf.synth.SynthLookAndFeel.getStyleFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。