What happens if you call setMinWidth(400)
on the last column instead of setPreferredWidth(400)
?
In the JavaDoc for JTable
, read the docs for doLayout()
very carefully. Here are some choice bits:
When the method is called as a result of the resizing of an enclosing window, the
resizingColumn is null. This means that resizing has taken place “outside” the JTable
and the change – or “delta” – should be distributed to all of the columns regardless of
this JTable’s automatic resize mode.
This might be why AUTO_RESIZE_LAST_COLUMN
didn’t help you.
Note: When a JTable makes adjustments to the widths of the columns it respects their
minimum and maximum values absolutely.
This says that you might want to set Min == Max for all but the last columns, then set Min = Preferred on the last column and either not set Max or set a very large value for Max.