Hi all,
in order to set the background color to each row that has some value (1000 for example) in some colon, i made this DefaultTableCellRenderer :
class RowColorRenderer implements TableCellRenderer {
public static final DefaultTableCellRenderer MyDTCR = new DefaultTableCellRenderer();
public Component getTableCellRendererComponent(JTable TheTable,Object TheValue,boolean isSelected,boolean hasFocus,int row,int column)
{ Component renderer = MyDTCR.getTableCellRendererComponent(TheTable, TheValue, isSelected, hasFocus, row, column);
((JLabel) renderer).setOpaque(true);
Color foreground, background;
if (isSelected) {
foreground = Color.yellow;
background = Color.green;
}
else { if (TheTable.getValueAt(row,7).toString().equals("100 "))
{foreground = Color.blue;
background = Color.red;
}
else {foreground = Color.white;
background = Color.blue;
}
}
renderer.setForeground(foreground);
renderer.setBackground(background);
return renderer;
}
}
But, it does NOT work...
Thanks to anyone tell me what is wrong in the code ....