1、遍历删除是没有难,而重点在JTableModel每次删除都是删除0行,因为你删除后,JTableModel就会更新数据了
int tableRowCount = tableModel.getRowCount(); if(tableRowCount > 0){ int realDeleteRow = 0; for(int tableRowIndex=0;tableRowIndex<tableRowCount;tableRowIndex++){ tableModel.removeRow(realDeleteRow); //每次都是0行,这是关键 } }