I have a class;
public class A extends AbstractTableModel
{
...
}
Using ResultSetMetaData I build the TableModel to match my result set fr
I have adapted DefaultTableModel's addColumn method to a custom AbstractTableModel as follows. Assume that both the column identifiers (headers) and model data (localCache) are ArrayLists - the model data being an ArrayList of an ArrayList.
public void addColumn(String columnName, List columnData) {
headers.add(columnName);
colCount = headers.size();
if (columnData != null) {
for (int r = 0; r < localCache.size(); r++) {
((List)localCache.get(r)).add(columnData.get(r));
}
} else {
System.out.println("Null columnData passed");
}
fireTableStructureChanged();
}