problem with JTable

hii have created a table..but i need the colum width as per my choice..how to set the colum width..plz help...
[145 byte] By [deepak_cuceka] at [2007-11-27 2:06:48]
# 1
Read the API.JTable's getColumn followed by TableColumns setWidth.
masijade.a at 2007-7-12 1:54:11 > top of Java-index,Desktop,Core GUI APIs...
# 2

Hey here is a sample code 4 adjusting the width of 3 colums:

TableColumn column1 = null;

for (int i = 0; i < 3; i++) {

column1 = table.getColumnModel().getColumn(i);

if (i == 0) {

column1.setPreferredWidth(20);

} else {

if (i == 1){

column1.setPreferredWidth(160);

}

else

{

column1.setPreferredWidth(80);

}

}

}

Satanduvel

Satanduvela at 2007-7-12 1:54:11 > top of Java-index,Desktop,Core GUI APIs...