You need to clear the graphics context before doing a new drawing by calling the super method that you have commented out.
//super.paintComponent(g);
Type: Posts; User: Norm
You need to clear the graphics context before doing a new drawing by calling the super method that you have commented out.
//super.paintComponent(g);
Is that the answer for question 3) or is that just for the code in the timer?
What about the other questions in post #12?
What prints out from the printlns you should be adding?
What are your answers to the questions I asked in post #12?
How are you doing the debugging?
I use calls to println statements that print out the values of variables so I can see what the computer sees. If you know what you want the code to do, then when you...
Where does the code change the location of the snake? How often is the draw() method called?
Do the x & y values for the snake's location ever change?
Why does the code call repaint() so many...
The code you posted is incomplete. It's missing the end of the source.
I think there is more than one problem. Which one are you working on?
To see what the code is doing, try debugging it by adding some println statements that print out the values of variables that control execution and the location of the shapes. The print out will...
When I execute the code I see a red shape and a blue shape at random locations.
The red shapes moves when a keyboard arrow is pressed.
Can you explain what the code is supposed to do?