It's not a secret anymore!
The moose likes Beginning Java and the fly likes What am I doing wrong here? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What am I doing wrong here? " Watch "What am I doing wrong here? " New topic

What am I doing wrong here?

Christopher Dee

Joined: Oct 08, 2002
Posts: 2
I'm sorry if you get a lot of these questions here, but I really am straining to see what I'm doing wrong.
My problem is with the getImage method. I've used it in a number of applets so far, and I haven't had any difficulty with it. But for some reason, this one particular applet returns a " cannot resolve symbol - symbol : method getCodeBase ()" error when I try to compile. Not that that's very helpful.
I've re read through the section of my web tutorial that covers images, and I'll still can't figure out how I'm using it wrongly.
Here is the code. Can anyone spot the error?
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ October 15, 2002: Message edited by: Dirk Schreckmann ]
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
getCodeBase() is not a method defined in your class nor the Canvas class that it extends. So, that's why the compiler is basically telling you that it doesn't understand getCodeBase().
getCodeBase() is a method of Applet, maybe that's why you are confused?

Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
If you'd like to add an image to your canvas, you may find the java.awt.Toolkit class to be useful.
And for a more direct hint...
Image myImage = Toolkit.getDefaultToolkit().getImage( String or URL );

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: What am I doing wrong here?
It's not a secret anymore!