Cell rendering in a JTable

asd_at_asd.com
Date: 05/09/04


Date: Sun, 09 May 2004 04:47:59 GMT

I need to make the cells in the 1st column look like the column
header. I tried the following code but it didn't change anything:

private void rendererTest()
    {
        TableColumn column =
tblDecisions.getColumnModel().getColumn(0);
        TableCellRenderer renderer = column.getHeaderRenderer();
        column.setCellRenderer(renderer);
    }

I've also tried subclassing my JTable by doing the following:

class DecisionMatrixTable extends JTable
    {

        DecisionMatrixTable(TableModel model)
        {
            super(model);
        }

        public TableCellRenderer getCellRenderer(int row, int column)
        {
            TableCellRenderer ren =
this.getColumnModel().getColumn(0).getHeaderRenderer();
            if (column == 0)
            {
                return ren;
            }
            return super.getCellRenderer(row, column);
        }
    }

In this case I get a NullPointerException on "ren".

Help would be much appreciated.

Reply preferrably via email to tdk13@perfectsolve.com

Thanks.



Relevant Pages

  • Cell rendering in a JTable
    ... I need to make the cells in the 1st column look like the column ... header. ... private void rendererTest() ... In this case I get a NullPointerException on "ren". ...
    (comp.lang.java)
  • Cell rendering in a JTable
    ... I need to make the cells in the 1st column look like the column ... header. ... private void rendererTest() ... In this case I get a NullPointerException on "ren". ...
    (comp.lang.java.programmer)
  • Cell rendering in a JTable
    ... I need to make the cells in the 1st column look like the column ... header. ... private void rendererTest() ...
    (comp.lang.java.gui)
  • Cell rendering in a JTable
    ... I need to make the cells in the 1st column look like the column ... header. ... private void rendererTest() ...
    (comp.lang.java.programmer)
  • Cell rendering in a JTable
    ... I need to make the cells in the 1st column look like the column ... header. ... private void rendererTest() ...
    (comp.lang.java)