Hi,
I wanted to change the color of the first two rows of a Jtable .How do i achieve that?
I have written the follow:
TableCellRenderer render1 = null;
render1 = new myCellRenderer();
And the renderer is written as :
class myCellRenderer extends DefaultTableCellRenderer implements TableCellRenderer
{
private static final long serialVersionUID = 1L;
public myCellRenderer()
{
setBackground(Color.gray);
}
public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,int row,int column)
{
System.out.println("Row value is " + row);
Component comp = getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (row == 0 || row == 1)
{
comp.setBackground(Color.blue);
}
return comp;
}
}
This does not enter the getTableRendererComponent at all.
What am I doing wrong?