When I remove the selected rows from the JTable its working fine but if I sort the row in some order then its tblModel.removeRow()
is removing the row in wrong order.
Please help.Thanks.
//Storing the selectedrows into rows[]
int[] rows = userTable.getSelectedRows();
for (int a = rows.length-1 ; a >= 0; a--) {
//Converting the rowindex to model row index
int rowid= userTable.convertRowIndexToModel(rows[a]);
//Converting the rowindex to model column index
int colid= userTable.convertColumnIndexToModel(0);
if(um.deleteUser((int) tblModel.getValueAt(rowid, colid))==true){
//Everything is good upto here but this line removes the wrong row if the row is sorted
tblModel.removeRow(rows[a]);
JOptionPane.showMessageDialog(null,"Deleted");
MyDashboard d = new MyDashboard();
d.setStatusText("Deleted");
}
}