-2

这是我的表模型:

public class d9tableModel extends AbstractTableModel {

ArrayList<String> cols = new ArrayList<>();
ArrayList<ArrayList<String>> data = new ArrayList<>();

public d9tableModel() {
// initial cols and data with database
}

@Override
public int getRowCount() {
    return data.size();
}

@Override
public int getColumnCount() {
    return cols.size();
}

@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    ArrayList<String> selectedRow = data.get(rowIndex);
    return selectedRow.get(columnIndex);
}

@Override
public String getColumnName(int column) {
    return cols.get(column);
}

public void removeRow(int rowNumber) {
    data.remove(rowNumber);
}
}

现在,在传递convertRowIndexToModel行号后,不要删除行!

4

1 回答 1

1

改变这个

 public void removeRow(int rowNumber) {
        data.remove(rowNumber);
    }

public void removeRow(int rowNumber) {
    data.remove(rowNumber);
    fireTableRowsDeleted(rowNumber, rowNumber);
}
于 2013-07-30T22:50:11.397 回答