swing调整table列宽

2014-11-24 02:57:37 · 作者: · 浏览: 0

/**
* 调整列宽
*/
private void adjustColumnWidth() {
// Tweak the appearance of the table by manipulating its column model
TableColumnModel colmodel = table.getColumnModel();

// Set column widths
colmodel.getColumn(0).setPreferredWidth(20);
colmodel.getColumn(1).setPreferredWidth(20);
colmodel.getColumn(2).setPreferredWidth(40);
colmodel.getColumn(3).setPreferredWidth(80);
colmodel.getColumn(4).setPreferredWidth(200);
colmodel.getColumn(5).setPreferredWidth(5);
}

作者“hzhlu”