I have a JTable with 3 columns:
- No. #
- Name
- PhoneNumber
I want to make specific width for each column as follows:
I actually run into this problem too. I've found one useful link that solved my issue. Pretty much get the specific column and set its setMinWidth and setMaxWidth to be the same(as fixed.)
private void fixWidth(final JTable table, final int columnIndex, final int width) {
TableColumn column = table.getColumnModel().getColumn(columnIndex);
column.setMinWidth(width);
column.setMaxWidth(width);
column.setPreferredWidth(width);
}
Ref: https://forums.oracle.com/thread/1353172