Help w/adding a TableColumn

asd_at_asd.com
Date: 04/28/04


Date: Wed, 28 Apr 2004 15:27:07 GMT

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
tdk13@perfectsolve.com

Thanks,

Tamir



Relevant Pages

  • Adding a TableColumn?
    ... I need to modify any given column's header in my JTable. ... TableColumn and re-add a TableColumn into the same position. ... Tamir ...
    (comp.lang.java.gui)
  • Help w/adding a TableColumn
    ... I need to modify any given column's header in my JTable. ... TableColumn and re-add a TableColumn into the same position. ... Tamir ...
    (comp.lang.java.programmer)
  • How can I resize a JTables column width?
    ... JTableHeader which is wrapped around a DefaultTableColumnModel object that ... After I start the application, the header of the table looks good, but the ... but why don't the cell values show up? ... TableColumn firstCol = new TableColumn; ...
    (comp.lang.java.programmer)
  • How can I resize a JTables column width?
    ... JTableHeader which is wrapped around a DefaultTableColumnModel object that ... After I start the application, the header of the table looks good, but the ... but why don't the cell values show up? ... TableColumn firstCol = new TableColumn; ...
    (comp.lang.java.help)