本文整理了Java中javax.swing.JComboBox.getFontMetrics()
方法的一些代码示例,展示了JComboBox.getFontMetrics()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComboBox.getFontMetrics()
方法的具体详情如下:
包路径:javax.swing.JComboBox
类名称:JComboBox
方法名:getFontMetrics
暂无
代码示例来源:origin: org.ihtsdo/wb-api
public int getWidestItemWidth() {
int numItems = comboBox.getItemCount();
Font font = comboBox.getFont();
FontMetrics metrics = comboBox.getFontMetrics(font);
int widest = 0;
for (int i = 0; i < numItems; i++) {
Object item = comboBox.getItemAt(i);
int lineWidth = metrics.stringWidth(item.toString());
widest = Math.max(widest, lineWidth);
}
return widest;
}
}
代码示例来源:origin: cytoscape/application
FontMetrics fm = box.getFontMetrics(scrollPane.getFont());
w = (int)fm.stringWidth(wsp.getWidest());
h = (int)scrollPane.getMinimumSize().getHeight();
代码示例来源:origin: GoldenGnu/jeveassets
FontMetrics fontMetrics = jComboBox.getFontMetrics(jComboBox.getFont());
EnumTableColumn<E> longestColumn = null;
for (EnumTableColumn<E> column : allColumns) {
代码示例来源:origin: net.java.dev.swing-layout/swing-layout
FontMetrics fm = combobox.getFontMetrics(combobox.getFont());
return y + fm.getAscent();
代码示例来源:origin: net.java.dev.swing-layout/swing-layout
private int getComboBoxBaseline(JComboBox combobox, int height) {
Insets insets = combobox.getInsets();
int y = insets.top;
height -= (insets.top + insets.bottom);
if (combobox.isEditable()) {
ComboBoxEditor editor = combobox.getEditor();
if (editor != null && (editor.getEditorComponent() instanceof
JTextField)) {
JTextField tf = (JTextField)editor.getEditorComponent();
return y + getSingleLineTextBaseline(tf, height);
}
}
y -= 1;
// Use the renderer to calculate baseline
ListCellRenderer renderer = combobox.getRenderer();
if (renderer instanceof JLabel) {
return y + getLabelBaseline((JLabel)renderer, height);
}
// Renderer isn't a label, use metrics directly.
FontMetrics fm = combobox.getFontMetrics(combobox.getFont());
return y + fm.getAscent();
}
内容来源于网络,如有侵权,请联系作者删除!