I've tried this:
public void removeSelectedFromTable(JTable from)
{
int[] rows = from.getSelectedRows();
TableModel tm= from.getModel();
while(rows.length>0)
{
((DefaultTableModel)tm).removeRow(from.convertRowIndexToModel(rows[0]));
rows = from.getSelectedRows();
}
from.clearSelection();
}
But, it sometimes leaves one still there. What can be the problem?
It doesn't work, this is better:
public void removeSelectedRows(JTable table){
DefaultTableModel model = (DefaultTableModel) this.table.getModel();
int[] rows = table.getSelectedRows();
for(int i=0;i<rows.length;i++){
model.removeRow(rows[i]-i);
}
}