Hi all,
I have created a JTable.In that table column 2 have to show in color RED.It showing properly most of the times.Sometimes the first row of column 2 didn't showing properly.All other rows column2 showing.At that time it didn't go inside the method 'getTableCellRendererComponent()' for the first row.I don't know where is the problem?
here the code is,
public class YourTableCellRenderer extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(JTable table,Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
java.awt.Component c = super.getTableCellRendererComponent(table, value, isSelected,
hasFocus, row, column);
String strValue=(String)value;
if(strValue.equalsIgnoreCase("ON"))
c.setForeground(GREEN);
else if(strValue.equalsIgnoreCase("OFF"))
c.setForeground(Color.red);
else if(strValue.equalsIgnoreCase("UNKNOWN"))
c.setForeground(Color.blue);
}
}