移动行JTable时如何保持行颜色?

时间:2016-06-14 13:10:35

标签: java swing jtable defaulttablemodel

当我在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);
}

0 个答案:

没有答案
相关问题