Oh, wow, Greg is right. I overlooked that. Instead of the classes inheriting from JComponent, they should probably be inheriting from Rectangle or some other drawable object, since you are trying to...
Type: Posts; User: aussiemcgr
Oh, wow, Greg is right. I overlooked that. Instead of the classes inheriting from JComponent, they should probably be inheriting from Rectangle or some other drawable object, since you are trying to...
Debuggers let you "step through the code", one statement at a time. It can be tedious, since it will take you through a bunch of silly java classes you don't care about, but that's the cost you pay...
No, it should be getting called in your constructor where you have the call to: repaint()
There must be something we are overlooking.
Ok, so we know:
1. You are creating a new SnakeFood object,...
Ok. So, your SnakeFood rectangle printout cannot possibly be correct. Look at your width and height variables in the snakeFood class. They are set to 10, yet the printout says 14. Are you 100% sure...
Well the super call for that method is kinda important. You should always do the super.paintComponent(g) when you override the paintComponent() method. Have a look at: A Closer Look at the Paint...
Um, shouldn't this result in infinite recursion?
public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
g2.draw(food);
g2.setColor(Color.BLUE);
...