java.awt.Container.getFontMetrics()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(138)

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

Container.getFontMetrics介绍

暂无

代码示例

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

Container titleBar = (Container) dialog.getLayeredPane().getComponents()[1];
FontMetrics metrics = titleBar.getFontMetrics(titleBar.getFont());
int width = metrics.stringWidth(getTitle());

代码示例来源:origin: markiewb/nb-codeoutline

/**
 * Make sure font metrics information cached by the view is up-to-date.
 */
protected void checkMetrics()
{
  Component host = getContainer();
  Font f = host.getFont();
  if (currentFont != f) {
    // The font changed, we need to recalculate the
    // longest line.
    currentFont = f;
    metrics = getContainer().getFontMetrics(currentFont);
    longestLine = null;
    tabSize = getTabSize() * metrics.charWidth('m');
  }
}

代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker

/**
 * Computes and returns the width of this Size's prototype in pixel. Ignores the component list
 * and measures. Obtains the FontMetrics from the given layout {@code container} for the default
 * dialog font provided by {@link DefaultUnitConverter#getDefaultDialogFont()}
 * .<p>
 *
 * Invoked by {@link com.privatejgoodies.forms.layout.FormSpec} to determine the size of a
 * column or row.
 *
 * @param container the layout container
 * @param components the list of components used to compute the size
 * @param minMeasure the measure that determines the minimum sizes
 * @param prefMeasure the measure that determines the preferred sizes
 * @param defaultMeasure the measure that determines the default sizes
 *
 * @return the {@code stringWidth} for this size's prototype string computed by the
 * {@code container}'s FontMetrics for the {@code DefaultUnitConverter}'s default dialog font
 */
@Override
public int maximumSize(Container container,
    List components,
    FormLayout.Measure minMeasure,
    FormLayout.Measure prefMeasure,
    FormLayout.Measure defaultMeasure) {
  Font font = DefaultUnitConverter.getInstance().getDefaultDialogFont();
  FontMetrics fm = container.getFontMetrics(font);
  return fm.stringWidth(getPrototype());
}

代码示例来源:origin: com.jgoodies/forms

/**
 * Computes and returns the width of this Size's prototype in pixel.
 * Ignores the component list and measures. Obtains the FontMetrics
 * from the given layout {@code container} for the default dialog font
 * provided by {@link DefaultUnitConverter#getDefaultDialogFont()}.<p>
 *
 * Invoked by {@link com.jgoodies.forms.layout.FormSpec} to determine
 * the size of a column or row.
 *
 * @param container       the layout container
 * @param components      the list of components used to compute the size
 * @param minMeasure      the measure that determines the minimum sizes
 * @param prefMeasure     the measure that determines the preferred sizes
 * @param defaultMeasure  the measure that determines the default sizes
 *
 * @return the {@code stringWidth} for this size's prototype string
 *    computed by the {@code container}'s FontMetrics for the
 *    {@code DefaultUnitConverter}'s default dialog font
 */
public int maximumSize(Container container,
        List components,
        FormLayout.Measure minMeasure,
        FormLayout.Measure prefMeasure,
        FormLayout.Measure defaultMeasure) {
  Font font = DefaultUnitConverter.getInstance().getDefaultDialogFont();
  FontMetrics fm = container.getFontMetrics(font);
  return fm.stringWidth(getPrototype());
}

代码示例来源:origin: com.jgoodies/jgoodiesforms

/**
 * Computes and returns the width of this Size's prototype in pixel.
 * Ignores the component list and measures. Obtains the FontMetrics
 * from the given layout {@code container} for the default dialog font
 * provided by {@link DefaultUnitConverter#getDefaultDialogFont()}.<p>
 *
 * Invoked by {@link com.jgoodies.forms.layout.FormSpec} to determine
 * the size of a column or row.
 *
 * @param container       the layout container
 * @param components      the list of components used to compute the size
 * @param minMeasure      the measure that determines the minimum sizes
 * @param prefMeasure     the measure that determines the preferred sizes
 * @param defaultMeasure  the measure that determines the default sizes
 *
 * @return the {@code stringWidth} for this size's prototype string
 *    computed by the {@code container}'s FontMetrics for the
 *    {@code DefaultUnitConverter}'s default dialog font
 */
@Override
public int maximumSize(Container container,
        List components,
        FormLayout.Measure minMeasure,
        FormLayout.Measure prefMeasure,
        FormLayout.Measure defaultMeasure) {
  Font font = DefaultUnitConverter.getInstance().getDefaultDialogFont();
  FontMetrics fm = container.getFontMetrics(font);
  return fm.stringWidth(getPrototype());
}

代码示例来源:origin: org.gephi/ui-components

int fontHeight = parent.getFontMetrics(font).getHeight();

代码示例来源:origin: com.github.insubstantial/flamingo

int fontHeight = parent.getFontMetrics(font).getHeight();

代码示例来源:origin: org.gephi/ui-components

int gap = getLayoutGap();
int fontHeight = parent.getFontMetrics(font).getHeight();

代码示例来源:origin: com.github.insubstantial/flamingo

int gap = getLayoutGap();
int fontHeight = parent.getFontMetrics(font).getHeight();
Font titleFont = font.deriveFont(Font.BOLD);

代码示例来源:origin: org.jclarion/clarion-runtime

FontMetrics fm = win.getFontMetrics(f);
int fw[] = fm.getWidths();
int wsum = 0;

相关文章

微信公众号

最新文章

更多

Container类方法