Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Images in applets won't compile!

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I couldn't figure out was how to make the following code work:

It won't compile?!!? How do I insert the images?
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
Mushu Wu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UPDATE: Yeah it compiled. When I try to run it though it says Start: applet not initialized. Here's the code again:
 
Every plan is a little cooler if you have a blimp. And a tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic