private void setFixedColumnWidth(final int columnIndex, String sampleText) {
   final TableColumn column =
       myEntryTable.getTableHeader().getColumnModel().getColumn(columnIndex);
   final FontMetrics fontMetrics = myEntryTable.getFontMetrics(myEntryTable.getFont());
   final int width = fontMetrics.stringWidth(" " + sampleText + " ") + JBUI.scale(4);
   column.setPreferredWidth(width);
   column.setMinWidth(width);
   column.setResizable(false);
 }
Exemplo n.º 2
0
 private int getWidth(JBTable deviceTable, String sampleText) {
   FontMetrics metrics = deviceTable.getFontMetrics(deviceTable.getFont());
   return metrics.stringWidth(sampleText);
 }