Hi
I am looking to remove columns from the view of a table using
javax.swing.table.TableColumn col = jTable1.getColumnModel().getColumn(1);
jTable1.removeColumn(col);
however, i still want to be able to reference this column later on. I was hoping that
table.getColumnModel().getColumnCount();
would return the number of underlying columns (which is 4) but it only returns 3
However,
table.getModel().getColumnCount()]
does return 4 columns but I cannot get the column index from this call.
in effect i want to do
for (int columnIndex = 0; columnIndex < selectedColumnNames.size(); columnIndex++) {
selectedColumnName = selectedColumnNames.get(columnIndex).toString();
modelIndex = table.getColumnModel().getColumnIndex(selectedColumnName);
// (above) throws illeageArgumentException as the column is not found as the column model only has 3 out of the 4 columns
row.add(table.getModel().getValueAt(rowIndex, modelIndex));
}
But cannot think of a way using the (default) table model. I am using the basic tableModel as i have many different classes that have their own type of TableModel (ie extend TableModel, or implement cant remember just now) but this one (TableModel) is implemented by all.
Would appreciate any help
Many thanks
Rudy