So I have a JTable with 24 columns. When the table is initialized, I make set the widths of the columns and the user interface looks great. No complaints. The user can click a button to only see 4 of the columns. I change the array of columns on the table model and then call
firetablestructurechanged()
which then removes all of the column widths I established (but now only shows the 4 columns, the intended behavior). When I try re-defining the column widths, nothing seems to change.
This is what I use to set column widths
TableColumnModel columnModel = table.getColumnModel();
for (int i = 1; i < columnModel.getColumnCount(); i++) {
columnModel.getColumn(i).setMinWidth(50);
columnModel.getColumn(i).setMaxWidth(50);
}
How do I get the columns to resize after firetablestructurechanged() gets called?