File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes Images in applets won't compile! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Images in applets won Watch "Images in applets won New topic
Author

Images in applets won't compile!

Mushu Wu
Greenhorn

Joined: Dec 02, 2003
Posts: 12
I couldn't figure out was how to make the following code work:

It won't compile?!!? How do I insert the images?


[img]http://www.mikestermedia.com/sig2/tag.png[/img]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi Mushu,
Welcome to JavaRanch!
Java is a strongly typed language, meaning that every variable has a data type associated with it. The line
Img1 = getImage (getCodeBase (), "Img1.gif");
doesn't declare what type the variable "Img1" has. It should be
Image Img1 = getImage (getCodeBase (), "Img1.gif");
(given that you add a "import java.awt.Image" up at the top.)


[Jess in Action][AskingGoodQuestions]
Mushu Wu
Greenhorn

Joined: Dec 02, 2003
Posts: 12
Thanks, I had tried that (adding Image as I suspected that was the case) before, but I didn't import the awt Image so I now know that is why I got a Cannot resolve symbol error from the compiler. However the *.java file that I downloaded yesterday (which this code was a derivitive of) didn't hava the "type" identifier (or whatever it's called). I guess I can count this as a lesson on object type and how that can effect the compiler.
Mushu Wu
Greenhorn

Joined: Dec 02, 2003
Posts: 12
UPDATE: Yeah it compiled. When I try to run it though it says Start: applet not initialized. Here's the code again:
 
Consider Paul's rocket mass heater.
 
subject: Images in applets won't compile!