i have Jtable in Java that inserting data from SQL
What i need to do if the Field Nummber 3 is = to 0
i need to set the backround of it to be Red and others is Not
Any Help ?
NoSelect:
WithSelect:
Edit : Try to use a different method to change the color using
TableCellRenderer RederColer = (JTable table, Object value, boolean isSelected, boolean hasFocus, int row1, int column) -> {
        if (table.getModel().getValueAt(row, 2).equals("0")) {
            setForeground(Color.RED);
        } else {
            setForeground(Color.white);
        }
        throw new UnsupportedOperationException("Not supported yet.");
    };
    model.setRowCount(0);
    jTable1.removeAll();
    Counter = 0;
    if ("En".equals(Lang)) {
        this.jButton2.setText("Exit");
    }
    db.DBConnect();
    try {
        String query = "SELECT * FROM `required_production` ORDER BY `required_production`.`DEAD_LINE` ASC";
        db.rs = db.st.executeQuery(query);
        Object[] columns = {call1, call2, call5, call3, call4};
        model.setColumnIdentifiers(columns);
        jTable1.setBackground(Color.white);
        jTable1.setForeground(Color.black);
        jTable1.setSelectionBackground(Classes.Setting.greenDF);
        jTable1.setRowHeight(30);
        jTable1.setFont(Classes.Setting.font);
        jTable1.setRowSelectionAllowed(true);
        jTable1.setDefaultEditor(Object.class, null);
        jTable1.setModel(model);
        Counter = 0;
        while (db.rs.next()) {
            model.addRow(new Object[]{db.rs.getString("REQUIRED_PRODUCT"), db.rs.getString("REQUIRED_NUMBER"), db.rs.getString("REMAINING_NUMBER"), db.rs.getString("REQUIRED_COLOR"), db.rs.getString("DEAD_LINE")});
            IDIn[Counter] = db.rs.getString("ID");
            Counter = Counter + 1;
             jTable1.getColumnModel().getColumn(2).setCellRenderer(RederColer);
        }
    } catch (SQLException error) {
    }
enter code here

