javax.swing.JLabel.getUI()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中javax.swing.JLabel.getUI()方法的一些代码示例,展示了JLabel.getUI()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.getUI()方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:getUI

JLabel.getUI介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-inspect

/**
 * Returns the background or foreground color of the given label.
 * We cannot use {@code getBackground()} or {@code getForeground()}
 * method because the given label is {@code HTMLRendererImpl} that
 * handles its background and foreground in a non-standard way.
 *
 * @param label label whose background or foreground should be returned.
 * @param foreground if true then the method returns the foreground
 * color, it returns background color otherwise.
 * @return background or foreground color of the given label.
 */
private Color color(JLabel label, boolean foreground) {
  Color color = null;
  Object htmlUI = label.getUI();
  try {
    String methodName = foreground ? "getForegroundFor" : "getBackgroundFor"; // NOI18N
    Method method = htmlUI.getClass().getDeclaredMethod(methodName, htmlRenderer.getClass()); // NOI18N
    method.setAccessible(true);
    Object result = method.invoke(null, htmlRenderer);
    if (result instanceof Color) {
      color = (Color)result;
    }
  } catch (IllegalAccessException ex) {
  } catch (IllegalArgumentException ex) {
  } catch (InvocationTargetException ex) {
  } catch (NoSuchMethodException ex) {
  }
  return color;
}

代码示例来源:origin: edu.stanford.protege/ca.uvic.cs.chisel.cajun

public void highlightLabel(String searchText) {
  LabelUI ui = getIconLabel().getUI();
  if (ui instanceof HighlightingLabelUI) {
    ((HighlightingLabelUI)ui).setHighlightText(searchText);
    getIconLabel().repaint();
  }
}

代码示例来源:origin: stackoverflow.com

g2d.dispose();
getUI().paint(g, this);

代码示例来源:origin: org.netbeans.api/org-openide-explorer

lbl.setForeground(getForeground());
lbl.setBorder( getBorder() );
if ((isGTK || "com.sun.java.swing.plaf.windows.WindowsLabelUI".equals(lbl.getUI().getClass().getName())) 
    && ! isEnabled() && ! htmlValueUsed) {

相关文章

微信公众号

最新文章

更多

JLabel类方法