How i can change the size of column in JTable?

When i create JTable and put data in it, its column takes larger size in the panel(larger than the datae.g if data is only 1 or 2 os such numbers ,the column size appears too large) .How can i set the column size to the data so the the space is utilised

[313 byte] By [amin_rashid] at [2007-9-26 2:46:36]
# 1
Start with something likeyourTable.getColumnModel().getColumn(0).setPreferredWidth(40);to make your columns have different widths. Trying to make the column widths adapt to the data in the columns is a lot more difficult, so try the simple solution first.
DrClap at 2007-6-29 10:30:08 > top of Java-index,Archived Forums,Java Programming...