When I attempt to add columns and headers to my dynamic table, I get no errors, but then again I get nothing showing up as a table either. However if I define some inital dummy columnNames in the
String array within the model, it adds columns, but they are all of the same header. What is my basic problem or misunderstanding? I'm not sure if I have included enough code snippets below, if not, let me know and I will supply, otherwise that may be part of the problem.
Appreciatively,
Gary
== Define JTable
table = new JTable(tblmodel);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setPreferredScrollableViewportSize(new Dimension(FORMWIDTH+200,325));
table.setBackground(Color.white);
== Add table headers
TableColumnModel tcm = table.getColumnModel();
for(int i=0; i<table.getColumnCount();i++)
{
TableColumn tc = tcm.getColumn(i);
tcm.addColumn(tc);
tc.setHeaderValue(colNames[i+1]);
}
== Define Table Model
class ResultSetTableModel extends AbstractTableModel {
ResultSetMetaData metadata; // Additional information about the results
int numcols, numrows; // How many rows and columns in the table
String[] columnNames = {};
Object[][] data = {};
.
.
.