This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes TurtleGraphics error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "TurtleGraphics error" Watch "TurtleGraphics error" New topic
Author

TurtleGraphics error

Vitor Mateucci
Greenhorn

Joined: Oct 06, 2011
Posts: 13
So i tryed to write this project from my java book

but when i excecute the program i get errors saying that the pacage TurtleGraphics does not exist, now i have Jdk1.7.0 installed has any one runned into this problem before?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
The JDK does not contain a "Turtlegraphics" package - that is probably something that was written by the authors of the book. You need to locate that (the book should tell you where you can get it), and add the relevant jar files to your classpath during compilation and runtime.

At a quick glance, it should contain at least a "StandardPen" class (which your code uses), but most likely more than that.

I note that your code does not have a "main" method, nor does it seem to initialize any GUI objects on which to draw; is the Turtlegraphics package supposed to handle that, or is the code not yet finished?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
I think there is a design error in that class, too. I think having a no-arguments constructor is mistaken. I don’t think you want to default to 0, 0. I would suggest you get rid of that constructor, and move the initialisation of pen and colour into the other constructor. Also consider whether you want a default colour; if not you would add a Color parameter to that constructor. And I would use the upper-case version of red: Color.RED. Upper-case is better style for constants. You can overload the constructor like that with a default colour, like this
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
I see I have a new and unusual spelling of SmilingFace
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TurtleGraphics error
 
Similar Threads
repainting JLabels on a JPanel
JLabel icon redrawing problem
Help With Snake Game
Smiling Face
AWT: Painting buttons