package com.its.wthr.ui;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;

public class SttsTableCellRenderer extends DefaultTableCellRenderer {

    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

        Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        String commStts = table.getModel().getValueAt(row, 3).toString();
        if (commStts.equals("성공")) {
            cell.setBackground(new Color(255, 255, 255, 255));
            String door = table.getModel().getValueAt(row, 7).toString();
            String fan = table.getModel().getValueAt(row, 8).toString();
            String heater = table.getModel().getValueAt(row, 9).toString();
            String video = table.getModel().getValueAt(row, 11).toString();
        } else {
            cell.setBackground(new Color(182, 97, 97, 176));
        }

        if (column != 2 && column != 5) {
            setHorizontalAlignment(SwingConstants.CENTER);
        } else {
            setHorizontalAlignment(SwingConstants.LEFT);
        }

        return cell;
    }
}
