Feb 08

By default the column widths of a JTable are automatically set for you. To fix the width of a specified column you need to use the TableColumn for the column (there’s one for each column).

    TableColumn column = table.getColumnModel().getColumn(columnIndex);
    column.setPreferredWidth(width);
    column.setMaxWidth(width);

written by objects \\ tags: , , , ,


One Response to “How to fix a JTable column width”

  1. Saxonio Says:

    Thank you! It’s so simple but I didn’t cross my mind. This is the best way to fix a column’s size that only contains a checkbox.

Leave a Reply

You must be logged in to post a comment.