Hi! This seems like a simple question, though maybe it belongs in the intermediate forum, but my code has a problem. When I try to compile, I get this message:
Java:37: paintBetterComponent(java.awt.Graphics) in CoolerSmear.MyCoolPanel cannot be applied to () youbrokeit.paintBetterComponent();
1 error
I was trying to modify one of the ready-bake-code classes from the book (the first animation) to make it re-smear when you click a button. Here's my code. I think the problem is in my catch block, ironically enough (serves me right for writing "System.out.println("Error at " + Math.random());", doesn't it?). Thanks in advance for your help!!
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
it tells you the problem
public void paintBetterComponent(Graphics g){
and when called
youbrokeit.paintBetterComponent();
which needs a Graphics object
(and don't even think about using getGraphics())
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32694
4
posted
0
Please always tell us which bookand use the CODE button, or your posting becomes illegible.
EJ Amber
Greenhorn
Joined: Aug 12, 2005
Posts: 8
posted
0
It needs a Graphics object, okay, but how do I do that? (And what's getGraphics()?)
And I didn't know that about the formatting, thanks. The book I referenced is Head First Java, second edition.