title: Change background color of JTable whole row based on column value
body: <p>So what I am trying to do, is to change the color of each row based on values inside of the last column.</p>
  
  <p>I already found this solution: <a href="https://stackoverflow.com/questions/24848314/change-background-color-of-jtable-row-based-on-column-value">Change Background Color of JTable</a> which worked very well.</p>
  
  <p>But in addition I want to switch the color of the row to green when the fourth column reaches the same value as the second one.</p>
  
  <p>I used the approach of Cristian Marian and wrote my own class</p>
  
  <pre><code>    @Override
  public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
      Component comp = super.prepareRenderer(renderer, row, column);
  
  
          int second = (int) this.getModel().getValueAt(row, 1);
          int forth = (int) this.getModel().getValueAt(row, 3);
          int kat = Kategorie.getNumber((String) this.getModel().getValueAt(row, 2)); 
          if (kat &gt; 0) {
              if (second == forth) {
                  comp.setBackground(Color.GREEN);
              } else {
                  comp.setBackground(Color.RED);
              }
          }
  
      return comp;
  }
  </code></pre>
  
  <p>Still only the last cell in each column changes to green instead of the whole one. But when I clock on the row, the whole row switches the color</p>
  
  <p>The values in the last column are changed by another frame.</p>
  
  <p>Table at the beginning:
  <a href="https://i.stack.imgur.com/qIIVf.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qIIVf.jpg" alt="http://i.stack.imgur.com/qIIVf.jpg"></a></p>
  
  <p>When the value in the last column reaches the same value as in the second one it looks like this:</p>
  
  <p>After reaching the given value:
  <a href="https://i.stack.imgur.com/pSzU7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pSzU7.jpg" alt="http://i.stack.imgur.com/pSzU7.jpg"></a></p>