repaint() in Java doesn't “re-paint” immediately?
I have a code like that: // 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 But when I change panel.repaint() to panel.paintComponent(panel.getGraphics()) , the out is right