title: repaint() in Java doesn't "re-paint" immediately?
body: <p>I have a code like that:</p>
  
  <pre><code>// In MyPanel.java
  public void paintComponent(Graphics g)
  {
      super.paintComponent(g);
      // Draw something
      mypanel_count++;
  }
  
  // In Test.java
  public void testLargeData()
  {
      while (notDone)
      {
          panel.repaint();
          // do huge work
          test_count++;
          System.out.println("Test_count: " + test_count + ", MyPanel_count: " + mypanel_count);
      }
  }
  
  // Output !!!
  Test_count: 752, MyPanel_count: 23
  Test_count: 753, MyPanel_count: 23
  Test_count: 754, MyPanel_count: 23
  Test_count: 755, MyPanel_count: 24
  </code></pre>
  
  <p>But when I change <code>panel.repaint()</code> to <code>panel.paintComponent(panel.getGraphics())</code>, the out is right:</p>
  
  <blockquote>
  <pre><code>Test_count: 752, MyPanel_count: 752
  Test_count: 753, MyPanel_count: 753
  Test_count: 754, MyPanel_count: 754
  Test_count: 755, MyPanel_count: 755
  </code></pre>
  </blockquote>
  
  <p>Why? <code>paintComponent</code> method works, but sometimes it's blind, so I don't want to use it. Anybody can give me some suggestions? Thanks!</p>