when I sort the row, the indexes of the rows doesn't seems to change at all - thus resulting the old row which was initially in that position before making any sort. here my code is
DefaultTableModel modelmachine = (DefaultTableModel) jTableMachine2.getModel();
TableRowSorter<DefaultTableModel> tr = new TableRowSorter<>(modelmachine);
jTableMachine2.setRowSorter(tr);
tr.setRowFilter(RowFilter.regexFilter(jTextField8.getText()));
Check out RowSorter's
convertRowIndexToModelandconvertRowIndexToViewmethods. You're probably getting the model index (the index in the model, which does not have the sorting applied), but you need the view index (the index of what you actually see).