title: JTable Cell Renderer
body: <p>I'm following some code I found, (Yes I understand how it works)
  It's from here :<a href="http://www.java-forums.org/awt-swing/541-how-change-color-jtable-row-having-particular-value.html#post1015">Code Link</a></p>
  
  <p>What i'm trying to do is set a cells Foreground color if the cells value is set to "yellow"</p>
  
  <p>Here is my Code:</p>
  
  <pre><code>public class Board extends JPanel{
  
  private static final long serialVersionUID = 1L;
  
  int boardHeight = 20;
  int boardWidth = 10;
  
  JTable table;
  
  public Board() {
      table = new JTable(this.boardHeight, this.boardWidth);
      table.setDefaultRenderer(String.class, new BoardTableCellRenderer());
      table.setFocusable(false);
      table.setShowGrid(false);
      table.setRowMargin(0);
      table.setIntercellSpacing(new Dimension(0,0));
      table.setRowSelectionAllowed(false);
      table.setVisible(true);
      this.add(table);
      this.setPreferredSize(new Dimension(table.getPreferredSize().width, (table.getPreferredSize().height + 85)));
  }
  
  public void paint(Graphics g) {
      table.setRowHeight(20);
      for (int x = 0; x &lt; this.table.getColumnCount(); ++x) {
          TableColumn col = this.table.getColumnModel().getColumn(x);
          col.setPreferredWidth(20);
      }
  }
  }
  </code></pre>
  
  <p>And the Cell Renderer</p>
  
  <pre><code>public class BoardTableCellRenderer extends DefaultTableCellRenderer {
  
  private static final long serialVersionUID = 1L;
  
  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int col) {
  
      Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
      String s = table.getModel().getValueAt(row, col).toString();
  
      if (s.equalsIgnoreCase("yellow")) {
          c.setForeground(Color.YELLOW);
      }
      else {
          c.setForeground(Color.WHITE);
      }
  
      return c;
  }
  }
  </code></pre>
  
  <p>The problem is it isn't changing, if I set any cells value to "yellow"</p>
  
  <p>Thanks in advance!</p>