Setting color of column in JTable

Hi,

i had a problem before where i needed to set the colour of a column in JTable; however that problem has been resolved as i have done;

table.getColumnModel().getColumn(0).setCellRenderer(new customTableCellRenderer());

and the renderer class is:

publicclass customTableCellRendererextends DefaultTableCellRenderer

{

public customTableCellRenderer()

{

}

public Component getTableCellRendererComponent(JTable table, Object value,boolean isSelected,boolean hasFocus,int row,int column)

{

if(column==0)

{

setBackground(Color.YELLOW);

}

returnthis;

}

}

however, my problem now is that the column does become rendered yellow but the text for that column disappears.

Any help would be most appreciated.

[1469 byte] By [Mayaa] at [2007-10-2 23:33:53]
# 1

You are missing a super call:public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)

{

super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); // <--

if(column==0)

{

setBackground(Color.YELLOW);

}

return this;

}

PhHeina at 2007-7-14 16:15:38 > top of Java-index,Desktop,Core GUI APIs...
# 2
yeah, that solved it.thanks for that.
Mayaa at 2007-7-14 16:15:38 > top of Java-index,Desktop,Core GUI APIs...