title: Swing JTable - Unable to repaint and change background of cells
body: <p>Hy everyone, </p>
  
  <p>I'm trying to do some calculations in a JTable after iteration and mark with different background the cells that I need.</p>
  
  <p>However, I have 2 problems at the moment:<br>
  1) Cells are not painted immediately, but after the whole iteration cycle<br>
  2) Areas are not painted properly - if I need to paint table[3, 4] and table[6, 5] it draws a rectangular from [3,4] up to [6, 5] instead of drawing the singular cells only.   </p>
  
  <p>About problem 1: could I call repaint() with priority without the need to finish everything and the JVM to decide whenever to paint? I try to do <code>fireTableCellUpdated()</code> and <code>fireTableDataChanged()</code> but they don't get updated.</p>
  
  <p>Here there is my custom cell renderer method that changes the BGcolor:</p>
  
  <pre><code>public Component getTableCellRendererComponent(JTable table, Object value,
      boolean isSelected, boolean hasFocus, int row,int column) {
      Component renderer = super.getTableCellRendererComponent(
          table, value, isSelected, hasFocus, row, column);
  
      if(value instanceof Color) {
          Color c = (Color) value;
          renderer.setBackground(c);
          System.out.println("BG change [" + row + ":" + column + "]");
      }
  
      return renderer;
  }
  </code></pre>
  
  <p>Here there is the loop where I paint my cells on a button click:</p>
  
  <pre><code>for(int paintJ = startIndex; paintJ &lt; endIndex; paintJ++) {
       CrossCellRenderer rend =  (CrossCellRenderer) jTable1.getCellRenderer(i,  paintJ)
             .getTableCellRendererComponent(jTable1, Color.blue, true, true, i, paintJ);
       crossTableModel.fireTableCellUpdated(i, paintJ);
       jTable1.revalidate();
       jTable1.repaint();
       try {
            Thread.sleep(1000);
       }   catch(InterruptedException ie) {
             System.err.println("Exception sleeping the thread.");
       }
   }
  </code></pre>
  
  <p>Any tips on that?</p>