I have made a custom AbstractTableModel. The constructor initialises the model with data from a file. However, I wish to add an extra column to the model (this is because of SQL limitations in its columns).
I seek to achieve this by adding to the initialisation code a call to an addColumn(String columnName, Vector columnData) method.
This addColumn method in my custom AbstractTableModel is derived directly from DefaultTableModel's addColumn method, including "fireTableStructureChanged()".
Yet when I run this code, fireTableStructureChanged() appears not to add my new Column and the JTable displays only with data from the file. Why might this be?
Here is a short indication of the code I am using:
public class Dummy extends AbstractTableModel {
public Dummy() {
//load data from SQL file into ResultSets
//transfer ResultSet.metadata into columnHeaders Vector<String>
//transfer ResultSet.data into columnDatums Vector<String>
fireTableChanged(null);
addColumn("Added Heading", (Vector)null);
}
public addColumn(String columnHeader, Vector columnData) {
columnHeaders.add(columnHeader);
// transfer columnData into columnDatums
fireTableStructureChanged();
}
}
Is it a listener problem - is nothing listening at this point in time to fireTableStructureChanged()?