本文整理了Java中javax.swing.JTable.getFontMetrics()
方法的一些代码示例,展示了JTable.getFontMetrics()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTable.getFontMetrics()
方法的具体详情如下:
包路径:javax.swing.JTable
类名称:JTable
方法名:getFontMetrics
暂无
代码示例来源:origin: org.nuiton.jaxx/jaxx-runtime
public static int computeTableColumnWidth(JTable table,
Font font,
int columnIndex, String suffix) {
int width = 0;
if (font == null) {
font = table.getFont();
}
// if (font == null) {
// TableColumn column = table.getColumnModel().getColumn(columnIndex);
// font = ((JComponent) column.getCellRenderer()).getFont();
// }
FontMetrics fontMetrics = table.getFontMetrics(font);
for (int i = 0, rowCount = table.getRowCount(); i < rowCount; i++) {
String key = (String) table.getModel().getValueAt(i, 0);
int w = fontMetrics.stringWidth(key + suffix);
if (w > width) {
width = w;
}
}
return width;
}
代码示例来源:origin: io.ultreia.java4all.jaxx/jaxx-runtime
public static int computeTableColumnWidth(JTable table, Font font, int columnIndex, String suffix) {
int width = 0;
if (font == null) {
font = table.getFont();
}
// if (font == null) {
// TableColumn column = table.getColumnModel().getColumn(columnIndex);
// font = ((JComponent) column.getCellRenderer()).getFont();
// }
FontMetrics fontMetrics = table.getFontMetrics(font);
for (int i = 0, rowCount = table.getRowCount(); i < rowCount; i++) {
String key = (String) table.getModel().getValueAt(i, 0);
int w = fontMetrics.stringWidth(key + suffix);
if (w > width) {
width = w;
}
}
return width;
}
代码示例来源:origin: neueda/jetbrains-plugin-graph-database-support
private int strWidth(String str) {
return table.getFontMetrics(table.getFont())
.charsWidth(str.toCharArray(), 0, str.length());
}
代码示例来源:origin: org.nuiton.jaxx/jaxx-runtime-swing
public static int computeTableColumnWidth(JTable table, Font font, int columnIndex, String suffix) {
int width = 0;
if (font == null) {
font = table.getFont();
}
// if (font == null) {
// TableColumn column = table.getColumnModel().getColumn(columnIndex);
// font = ((JComponent) column.getCellRenderer()).getFont();
// }
FontMetrics fontMetrics = table.getFontMetrics(font);
for (int i = 0, rowCount = table.getRowCount(); i < rowCount; i++) {
String key = (String) table.getModel().getValueAt(i, 0);
int w = fontMetrics.stringWidth(key + suffix);
if (w > width) {
width = w;
}
}
return width;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-docker-ui
public static void configureRowHeight(JTable table) {
int height = table.getRowHeight();
Font cellFont = UIManager.getFont("TextField.font");
if (cellFont != null) {
FontMetrics metrics = table.getFontMetrics(cellFont);
if (metrics != null) {
height = metrics.getHeight() + 2;
}
}
table.setRowHeight(Math.max(table.getRowHeight(), height));
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject
private int calculateColumnWidth(String txt) {
Font font = getTargetList().getFont();
FontMetrics fontMetrics = getTargetList().getFontMetrics(font);
int width = fontMetrics.stringWidth(txt);
return width;
}
代码示例来源:origin: com.googlecode.clearnlp/clearnlp
public TRTablePane(TableModelListener listener, StringIntPair[] tags)
{
setLayout(new BorderLayout());
j_table = new JTable();
j_table.setModel(new DefaultTableModel(new Object[][]{{0,"","",0,""}}, t_columns));
j_table.getModel().addTableModelListener(listener);
TableColumnModel columnModel = j_table.getColumnModel();
for (StringIntPair tag : tags)
setColumnEditor(columnModel, tag.s, tag.i);
add(j_table.getTableHeader(), BorderLayout.NORTH);
add(j_table, BorderLayout.CENTER);
t_height = j_table.getFontMetrics(j_table.getFont()).getHeight();
}
代码示例来源:origin: com.clearnlp/clearnlp
public TRTablePane(TableModelListener listener, StringIntPair[] tags)
{
setLayout(new BorderLayout());
j_table = new JTable();
j_table.setModel(new DefaultTableModel(new Object[][]{{0,"","",0,""}}, t_columns));
j_table.getModel().addTableModelListener(listener);
TableColumnModel columnModel = j_table.getColumnModel();
for (StringIntPair tag : tags)
setColumnEditor(columnModel, tag.s, tag.i);
add(j_table.getTableHeader(), BorderLayout.NORTH);
add(j_table, BorderLayout.CENTER);
t_height = j_table.getFontMetrics(j_table.getFont()).getHeight();
}
代码示例来源:origin: clearnlp/clearnlp
public TRTablePane(TableModelListener listener, StringIntPair[] tags)
{
setLayout(new BorderLayout());
j_table = new JTable();
j_table.setModel(new DefaultTableModel(new Object[][]{{0,"","",0,""}}, t_columns));
j_table.getModel().addTableModelListener(listener);
TableColumnModel columnModel = j_table.getColumnModel();
for (StringIntPair tag : tags)
setColumnEditor(columnModel, tag.s, tag.i);
add(j_table.getTableHeader(), BorderLayout.NORTH);
add(j_table, BorderLayout.CENTER);
t_height = j_table.getFontMetrics(j_table.getFont()).getHeight();
}
代码示例来源:origin: ganshane/shakey
FontMetrics fm = table.getFontMetrics( renderer.getFont() );
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial
table.getSelectionModel().addListSelectionListener(this);
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
table.setRowHeight(table.getFontMetrics(table.getFont()).getHeight() * 6 / 5);
component = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
component.getViewport().setBackground(table.getBackground());
代码示例来源:origin: edu.stanford.protege/protege-editor-owl
final JTable table = new JTable(tableModel);
table.setGridColor(new Color(240, 240, 240));
FontMetrics fontMetrics = table.getFontMetrics(table.getFont());
table.setRowHeight((fontMetrics.getLeading() * 2)
+ fontMetrics.getMaxAscent()
代码示例来源:origin: protegeproject/protege
final JTable table = new JTable(tableModel);
table.setGridColor(new Color(240, 240, 240));
FontMetrics fontMetrics = table.getFontMetrics(table.getFont());
table.setRowHeight((fontMetrics.getLeading() * 2)
+ fontMetrics.getMaxAscent()
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javafx2-project
/** Creates new form JFXApplicationParametersPanel */
public JFXApplicationMultiPropertyPanel(@NonNull PropertiesTableModel mdl) {
this.tableModel = mdl;
initComponents();
cellEditor = new PropertyCellEditor();
tableMultiProperties.setDefaultRenderer(Object.class, new PropertyCellRenderer());
tableMultiProperties.setDefaultEditor(Object.class, cellEditor);
tableMultiProperties.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
updateRemoveButton();
updateDefaultButtonLabel();
updateDefaultButtonState();
FontMetrics fm = tableMultiProperties.getFontMetrics(tableMultiProperties.getFont());
tableMultiProperties.setRowHeight(fm.getHeight() + 5);
}
代码示例来源:origin: chatty/chatty
table.setIntercellSpacing(new Dimension(0, 0));
table.setFont(table.getFont().deriveFont(Font.BOLD));
table.setRowHeight(table.getFontMetrics(table.getFont()).getHeight()+2);
add(new JScrollPane(table), gbc);
代码示例来源:origin: tinyMediaManager/tinyMediaManager
int width = tableMovies.getFontMetrics(tableMovies.getFont()).stringWidth(" 2000");
int titleWidth = tableMovies.getFontMetrics(tableMovies.getFont()).stringWidth(BUNDLE.getString("metatag.year")); //$NON-NLS-1$
if (titleWidth > width) {
width = titleWidth;
代码示例来源:origin: hneemann/Digital
MyTableModel dm = new MyTableModel(this.localDataField, cols, rows, modelSync);
table = new JTable(dm);
int widthOfZero = table.getFontMetrics(table.getFont()).stringWidth("00000000") / 8;
table.setDefaultRenderer(MyLong.class, new MyLongRenderer(dataBits));
for (int c = 1; c < table.getColumnModel().getColumnCount(); c++) {
代码示例来源:origin: tinyMediaManager/tinyMediaManager
int width = tableAssignedMovies.getFontMetrics(tableAssignedMovies.getFont()).stringWidth(" 2000");
int titleWidth = tableAssignedMovies.getFontMetrics(tableAssignedMovies.getFont()).stringWidth(BUNDLE.getString("metatag.year")); //$NON-NLS-1$
if (titleWidth > width) {
width = titleWidth;
代码示例来源:origin: org.jclarion/clarion-runtime
JTable t = table;
if (t != null) {
int height= t.getFontMetrics(t.getFont()).getHeight();
t.setRowHeight(height);
代码示例来源:origin: org.jclarion/clarion-runtime
table.setRowHeight(table.getFontMetrics(table.getFont()).getHeight());
table.setRowMargin(0);
configureColor(table);
内容来源于网络,如有侵权,请联系作者删除!