所以我在 MytableModel 中创建方法
public void removeRow(int row) {
if (getSelectedUser(row) != null) {
Authorisation.userMap.remove(getSelectedUser(row).getName());
list.remove(getSelectedUser(row));
System.out.println(list);
Registration.writeToFile();
}
fireTableRowsDeleted(row, row);
fireTableDataChanged();
}
然后在外部类中我创建方法
public void deleteFromTable() {
delete.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int index = usersTable.getSelectedRow();
model.removeRow(index);
}
});
}
并在其他类中调用为
AdminFrame af = new AdminFrame(frame);
af.deleteFromTable();
在从 ArrayList 中删除所选行之前,表未更新。怎么了?