I need my JTable to automatically re-size its column widths to fit the content. I found the TableColumnAdjuster class very useful. But there\'s a small problem. Say i have 5
setAutoResizeMode() will tell your table how to resize you should give it a try will all different options available to see the differences, in My case I wanted to specifically resize two columns and let it decide how to adjust all the other ones.
jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
TableColumnModel colModel=jTable1.getColumnModel();
colModel.getColumn(1).setPreferredWidth(25);
colModel.getColumn(2).setPreferredWidth(400);