I have looked at so many tutorials/examples (I've spent a LOT of time here http://docs.oracle.com/javase/tutorial/uiswing/components/table.html) and I still can't figure out how to properly use a JTable to represent data (it's all strings) that changes at runtime. I do NOT want it to be modifiable by selecting rows/cells. The data is modified by my program at runtime (including the amount of rows) AFTER the table is initially created (it's created empty).
I tried an inner class
private class PairingsTableModel extends AbstractTableModel {
...
public void setValueAt(String value, int row, int col) {
data[row][col] = value;
fireTableCellUpdated(row, col);
}
...
}
and my JTable is instantiated as follows
JTable pairingsTable = new JTable(new PairingsTableModel());
And it uses the data I provide as instance variables for pairingsTableModel but pairingsTable.getModel() doesn't seem to return the pairingsTableModel (calling pairingsTable.getModel().setValueAt("Hello",0,0) does nothing and Eclipse thinks I'm not using setValueAt anywhere)