我想知道:JTable
插入行后如何重新排序(重新排序)行?
我使用下一个代码:
TableModel model = new DefaultTableModel(rows, columns) {
public Class getColumnClass(int column) {
Class returnValue;
if ((column >= 0) && (column < getColumnCount())) {
returnValue = getValueAt(0, column).getClass();
} else {
returnValue = Object.class;
}
return returnValue;
}
};
JTable table = new JTable(model);
RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model);
table.setRowSorter(sorter);
JScrollPane pane = new JScrollPane(table);
这段代码工作正常,我可以毫无问题地添加新行,但我想在插入新行后使用第一列 ASC 再次重新排序......