JAVA Netbeans
JTable resultsTable;
DefaultTableModel myModel;
myModel = (DefaultTableModel) resultsTable.getModel();
String value = (String) myModel.getValueAt(resultsTable.getSelectedRow(), columnIndex)
I use JTable and DefaultTableModel to view a table of various information and I want to get the value of a specific column of the selected table index.
The code I wrote above works fine if: I use the GUI view (click on the name of the field I want to sort by table) The table is sorted correctly, but after that, when I select a row, it gets the value of the row that was there before sorting. This means that after sorting (using the JTable GUI) myModel and resultTable objects have different row indices.
How to sync these two?