javax.swing.JPanel.getFontMetrics()方法的使用及代码示例

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

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

JPanel.getFontMetrics介绍

暂无

代码示例

代码示例来源:origin: bobbylight/RSyntaxTextArea

/**
 * Creates a new style.
 *
 * @param fg The foreground color to use.
 * @param bg The background color to use.
 * @param font The font for this syntax scheme.
 * @param underline Whether or not to underline tokens with this style.
 */
public Style(Color fg, Color bg, Font font, boolean underline) {
  foreground = fg;
  background = bg;
  this.font = font;
  this.underline = underline;
  this.fontMetrics = font==null ? null :
    new JPanel().getFontMetrics(font); // Default, no rendering hints!
}

代码示例来源:origin: org.jfree/swtgraphics2d

/**
 * Returns the font metrics.
 *
 * @param font the font.
 *
 * @return The font metrics.
 */
@Override
public FontMetrics getFontMetrics(Font font) {
  return SWTUtils.DUMMY_PANEL.getFontMetrics(font);
}

代码示例来源:origin: info.aduna.commons/aduna-commons-graphics

public java.awt.FontMetrics getFontMetrics(java.awt.Font f) {
  return panel.getFontMetrics(f);
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-editor

/**
 * Creates a new syntax scheme.
 *
 * @param fg The foreground color to use.
 * @param bg The background color to use.
 * @param font The font for this syntax scheme.
 * @param underline Whether or not to underline tokens with this style.
 */
public Style(Color fg, Color bg, Font font, boolean underline) {
  foreground = fg;
  background = bg;
  this.font = font;
  this.underline = underline;
  this.fontMetrics = font==null ? null :
    new JPanel().getFontMetrics(font); // Default, no rendering hints!
}

代码示例来源:origin: com.fifesoft/rsyntaxtextarea

/**
 * Creates a new style.
 *
 * @param fg The foreground color to use.
 * @param bg The background color to use.
 * @param font The font for this syntax scheme.
 * @param underline Whether or not to underline tokens with this style.
 */
public Style(Color fg, Color bg, Font font, boolean underline) {
  foreground = fg;
  background = bg;
  this.font = font;
  this.underline = underline;
  this.fontMetrics = font==null ? null :
    new JPanel().getFontMetrics(font); // Default, no rendering hints!
}

代码示例来源:origin: org.nuiton.thirdparty/rsyntaxtextarea

/**
 * Creates a new syntax scheme.
 *
 * @param fg The foreground color to use.
 * @param bg The background color to use.
 * @param font The font for this syntax scheme.
 * @param underline Whether or not to underline tokens with this style.
 */
public Style(Color fg, Color bg, Font font, boolean underline) {
  foreground = fg;
  background = bg;
  this.font = font;
  this.underline = underline;
  this.fontMetrics = font==null ? null :
    new JPanel().getFontMetrics(font); // Default, no rendering hints!
}

代码示例来源:origin: edu.stanford.protege/org.coode.owlviz

public OWLClsNodeRenderer(Controller controller,
             VisualisedObjectManager manager,
             NodeLabelRenderer labelRenderer,
             OWLModelManager owlModelManager) {
  this.owlModelManager = owlModelManager;
  if (manager == null) {
    throw new NullPointerException("VisualisedObjectManager must not be null");
  }
  if (labelRenderer == null) {
    throw new NullPointerException("NodeLabelRenderer must not be null");
  }
  this.controller = controller;
  visualisedObjectManager = manager;
  JPanel pan = new JPanel();
  Font font = pan.getFont();
  labelFont = font.deriveFont(10.0f);
  if (labelFont == null) {
    logger.warn("Font is NULL!");
  }
  fontMetrics = pan.getFontMetrics(labelFont);
  if (fontMetrics == null) {
    logger.warn("Font metrics is NULL!");
  }
  setupArrows();
}

代码示例来源:origin: robo-code/robocode

private void setPreviewLabelFont(JPanel panel) {
  String fontName = (String) getFontNameComboBox().getSelectedItem();
  int fontStyleFlags = FontStyle.fromName((String) getFontStyleComboBox().getSelectedItem()).getFontStyleFlags();
  int fontSize = Integer.parseInt((String) getFontSizeComboBox().getSelectedItem());
  Font font = new Font(fontName, fontStyleFlags, fontSize);
  
  getPreviewLabel().setFont(font);
  FontMetrics fontMetrics = panel.getFontMetrics(font);
  int width = fontMetrics.stringWidth(getPreviewLabel().getText());
  int height = fontMetrics.getHeight();
  getPreviewLabel().setPreferredSize(new Dimension(width, height));
}

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

int last_level_indent = MIDDLE_LEVEL_INDENT
    + IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND).getIconWidth()
    + rowContainer.getFontMetrics(rowContainer.getFont()).charWidth(' ');
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));

代码示例来源:origin: edu.stanford.protege/org.coode.owlviz

fontMetrics = pan.getFontMetrics(labelFont);

代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf

protected void enableIdOnTitleBar() {
  TableLayout layout = (TableLayout) titleBar.getLayout();
  layout.setColumn(0,
           titleBar
               .getFontMetrics(titleBar.getFont())
               .stringWidth(
                   resourceManager.getUserString(toolWindow.getId())
               )
           + 12);
  SwingUtil.repaint(titleBar);
}

代码示例来源:origin: net.java.dev.swing-layout/swing-layout

borderInsets = EMPTY_INSETS;
FontMetrics fm = panel.getFontMetrics(font);
int fontHeight = fm.getHeight();
int descent = fm.getDescent();

代码示例来源:origin: net.java.dev.swing-layout/swing-layout

borderInsets = EMPTY_INSETS;
FontMetrics fm = panel.getFontMetrics(font);
int fontHeight = fm.getHeight();
int descent = fm.getDescent();

代码示例来源:origin: org.jfree/swtgraphics2d

java.awt.Font tmpAwtFont = new java.awt.Font(fontData.getName(),
    fontData.getStyle(), height);
if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
    > tmpGC.textExtent(Az).x) {
  while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
      > tmpGC.textExtent(Az).x) {
    height--;
else if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
    < tmpGC.textExtent(Az).x) {
  while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
      < tmpGC.textExtent(Az).x) {
    height++;

代码示例来源:origin: org.jfree/swtgraphics2d

tmpGC.setFont(tmpFont);
if (tmpGC.textExtent(Az).x
    > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
  while (tmpGC.textExtent(Az).x
      > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
    tmpFont.dispose();
    height--;
    < DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
  while (tmpGC.textExtent(Az).x
      < DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
    tmpFont.dispose();
    height++;

代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf

titleBarLayout.setColumn(0, titleBar.getFontMetrics(
    titleBar.getFont()
).stringWidth(resourceManager.getUserString(id)) + 12);

相关文章

JPanel类方法