I want to color a Table row depending on whether there is a non-null in its 3rd column. Heres the code that I wrote : (ignore the braces)
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
JComponent c =(JComponent) super.prepareRenderer(renderer, row, column);
c.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1));
if (column == 2 ){
String value = (String) getValueAt(row, column);
System.out.println(value);
if (! value.equals(null)){
c.setForeground(Color.RED);
}
}
The problem is when I execute this all the rows of the table get colored even if only 1 row has a non-null value in the 3rd column. Where am I going wrong?