dcsimg

How can I set the width of a JTable column?

Betty Pang

Try the following:


table.getColumn(columnID).setMaxWidth(idealWidth); 
table.getColumn(columnID).setMinWidth(idealWidth); 
table.getColumn(columnID).setWidth(idealWidth); 
table.getColumn(columnID).setPreferredWidth(idealWidth);