I didn't call super.paintMethod() in my paintMethod, yet, every time the code runs, it wipe the window clean for some reason. Any suggestions? Here's my code.
for (int i = 0; i < 1000; i++) {
frame.repaint();
Thread.sleep(250);
P.x += 50;
if (P.x == 450) {
P.x = 0;
P.y += 50;
}
frame.repaint();
Does it. By default Component#paintComponent()
will render the background color on every repaint call.
Though if you override this method, and you don't call super.paintComponent()
, this step is omitted, causing an overlap painting.