当我在JTable
Swing中移动一行时,如何保持行颜色?这是我的代码我直接在表模型中移动行。
void moveRow(int row, int direction){ // direction in {-1, 1}
direction += row;
DefaultTableModel model =(DefaultTableModel) table.getModel();
Object obj1 = model.getRow(row);
Object obj2 = model.getRow(direction);
model.setRow(row, obj2);
model.setRow(direction, obj1);
table.setRowSelectionInterval(direction, direction);
}