title: Change background color of JTable row based on column value
body: <p>hi i am new in java jtable cellrendered. I am looking for a way that works in my program but i dont have any luck finding it.
  Here is my Jtable </p>
  
  <pre><code>Employee ID   |   Name     |   Status    |   Position
    00565651        Roger       Active        Manager
    00565652        Gina        Active        Crew
    00565652        Alex        Inactive      Crew
    00565652        Seph        Active        Manager    
  </code></pre>
  
  <p>the data came from ms access database but i want to change the background/foreground of the rows which has a value of "inactive" in status column. I found many examples in the internet but all of it is not possible in my program. Can someone help me? 
  This is my model</p>
  
  <pre><code>String[] columnNames = {"Employee ID","Name", "Status", "Position"};
  DefaultTableModel model = new DefaultTableModel(columnNames, 0);
  </code></pre>
  
  <p>and this is the way to create my table and how i am fetching data from database</p>
  
  <pre><code>public MyList(){//my constructor
      frame();
      loadListFromDB();
  }
  public void frame(){//
     //codes for frame setsize,titles etc...
     tblList = new JTable();
     tblList.getTableHeader().setPreferredSize(new Dimension(100, 40));
     tblList.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 25));
     tblList.setAutoCreateRowSorter(true);
     tblList.setModel(model);
     scrollPane.setViewportView(tblList);
     loadListFromDB();
  
  }
  public void loadListFromDB(){
     String sql = "SELECT emp_id,lname,fname,positional_status from tblEmployee";
      try{
          PreparedStatement ps = conn.prepareStatement(sql);
          ResultSet rs = ps.executeQuery();
          while (rs.next()){
              Vector row = new Vector();
              for (int i = 1; i &lt;= 4; i++){
                  row.addElement( rs.getObject(i) );
              }
              model.addRow(row);
          }
      }catch(Exception err){
          //for error code
      }
  }
  </code></pre>
  
  <p>How am i suppose to add the tableredered in this way?Can anyone give simple example to change the color of row? Thanks in advance.. My program stop in this problem. </p>