By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,554 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,554 IT Pros & Developers. It's quick & easy.

Help w/adding a TableColumn

P: n/a
asd
I need to modify any given column's header in my JTable. I couldn't
find a way of doing this, so I attempted to remove the necessary
TableColumn and re-add a TableColumn into the same position. The
problem I'm having is that it adds the TableColumn to the end of the
JTable, even when I set the appropriate index in the TableColumn
constructor. I've tried adding the TableColumn to the JTable and its
DefaultTableModel, neither works.

Here is the code I'm using:

TableColumn newCol = new TableColumn(index);
newCol.setHeaderValue(new String("New"));
TableColumn oldCol =
tblDecisionMatrix.getColumnModel().getColumn(index );
//tblDecisionMatrix.removeColumn(oldCol);
//tblDecisionMatrix.addColumn(newCol);

TableColumnModel colMdl = tblDecisionMatrix.getColumnModel();
colMdl.removeColumn(oldCol);
colMdl.addColumn(newCol);

Any help would be much appreciated. Please email replies to
td***@perfectsolve.com

Thanks,

Tamir

Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.