For a JTable that's inside a panel, if the panel is made larger, how can I distribute the extra space to only certain columns (in my case, to the last column, though it may be nice to offer "columns 3,4, and 8 will get the extra space).
I want to allow the user to change column sizes for all the columns manually.
I tried table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); That distributes the extra space to all the columns that are resizeable when the JTable is resized. In the the JavaDoc for JTable, for doLayout(), says:
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.
There may be a way to intercept a "JTable is resizing" event, and do something custom, though I haven't been able to figure it out.
Another solution is presented in How to exclude columns from auto-resizing in a JTable Though it doesn't really tell me how to do it in swing.