TableColumn column = null;while (int i = 0; i < table.getColumnCount(); i++) {
    column = table.getColumnModel().getColumn(i);
    column.setPreferredWidth(200);
}

解决方案 »

  1.   

    JTable testtable = new JTable();
    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
    *************************************************************
      

  2.   

    直接在getColumn里面写列名的字符串就应该可以了,查API才是王道啊。
    不过似乎mahaixing(猪的克星)的方法更好理解一些。
    我也是新手,学习。