import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
public class MyRenderer extends DefaultTableCellRenderer {
Color background;
Color foreground;
public MyRenderer(Color background, Color foreground) {
super();
this.background = background;
this.foreground = foreground;
}
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int fila, int columna) {
Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, fila, columna);
String valor = table.getValueAt(2, columna).toString();
if (valor.equalsIgnoreCase("Ocupada")) {
cell.setBackground(Color.red);
} else {
cell.setBackground(Color.GREEN);
}
return cell;
}
}