I am trying to change the color of entire row due to a column's value.
the columns I test it's value is the third one in my table.
Here is my cell rendering class code :
public class CustomTableCellRenderer extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(JTable table,
Object obj, boolean isSelected, boolean hasFocus, int row, int column) {
Component cell = super.getTableCellRendererComponent(
table, obj, isSelected, hasFocus, row, column);
String etat = (String) table.getModel().getValueAt(row, 2);
switch (etat) {
case "Annulé":
cell.setBackground(Color.RED);
break;
case "Traitement":
cell.setBackground(Color.yellow);
break;
case "Livré":
cell.setBackground(Color.GREEN);
break;
default :
// Here I want to change the color to the default color
}
return cell;
}
}
in my test I only included three cases, and I want in the default case my row to be colored by the default color which is provided by the look & feel.
How can I do that ?