Hi,
Im having a little bit of trouble when trying to set the width of the columns in a JTable,
the table is inside a JScrollPane and i have used:
this.jTable1.setAutoResizeMode(jTable1.AUTO_RESIZE_OFF);
so that the columns are not automatically resized to fit within the original table and the horizontal scroll bar is used instead(i add columns depending on no of search terms so sould be anywhere between 1 and 100),
however, i am trying to set the width of column 0 and cannot get it to work no matter what i try....
my code looks like the following: (the commented parts have been tried and did not suceed),
public void tableSet(){
this.jTable1.setAutoResizeMode(jTable1.AUTO_RESIZE_OFF);
jTable1.getColumnModel().getColumn(0).setPreferredWidth(400);
jTable1.getColumnModel().getColumn(0).setMaxWidth(400);
jTable1.getColumnModel().getColumn(0).setMinWidth(400);
// TableColumn col = jTable1.getColumnModel().getColumn(0);
// col.setPreferredWidth(300);
// col.setMinWidth(400);
// col.setMaxWidth(400);
for (int i = 0; i < this.terms.size(); i++) {
this.myModel.addColumn(this.terms.get(i));
}
any ideas?
thanks for your time