override the tablemodel method removeRow(int) like this: public void removeRow(int rowIndex) { data.remove(rowIndex); this.fireTableRowsDeleted(rowIndex, rowIndex); }data is the model you maintain in the model.
to Acylas(Acylas) 这种做法是错误的吧,删除几个后tableModel的行数就变了啊,removeRow的时候就会造成数组下标越界。不知道楼上的方法可不可行呢,我先试试
{
data.remove(rowIndex);
this.fireTableRowsDeleted(rowIndex, rowIndex);
}data is the model you maintain in the model.
这种做法是错误的吧,删除几个后tableModel的行数就变了啊,removeRow的时候就会造成数组下标越界。不知道楼上的方法可不可行呢,我先试试
我没有实际操作过,不知道getSelectedRows()返回的数组本身就是升序的,如果是这样更简单.
循环的时候这样写for(int i=sr.length;i>0;i--),世界又清静啦~~~~~