TableColumn column = null;while (int i = 0; i < table.getColumnCount(); i++) {
column = table.getColumnModel().getColumn(i);
column.setPreferredWidth(200);
}
column = table.getColumnModel().getColumn(i);
column.setPreferredWidth(200);
}
testtable.getColumn(Object identifier).setPreferredWidth(int preferredWidth);
*************************************************************
getColumn
public TableColumn getColumn(Object identifier)
Returns the TableColumn object for the column in the table whose identifier is equal to identifier, when compared using equals. Parameters:
identifier - the identifier object
Returns:
the TableColumn object that matches the identifier
Throws:
IllegalArgumentException - if identifier is null or no TableColumn has this identifier
*************************************************************
不过似乎mahaixing(猪的克星)的方法更好理解一些。
我也是新手,学习。