JAVA NETBEANS
// resultsTable, myModel
JTable resultsTable;
DefaultTableModel myModel; //javax.swing.table.DefaultTableModel
myModel = (DefaultTableModel) resultsTable.getModel();
// event of clicking on item of table
String value = (String) myModel.getValueAt(resultsTable.getSelectedRow(), columnIndex)
I use JTable and DefaultTableModel to view a table of various info and I want to get a value of a certain column of the selected index of the table.
The code I wrote above works fine except when: I use the sort of the GUI (click on the field name I want to sort on the table) The table is properly sorted but after that when I select a row, it gets the value of the row that was there before the sort. This means that after sorting (using the JTable's GUI) the 'myModel' and 'resultsTable' objects have different row indexes.
How do I synchronize those two?