Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loading image on applet

 
Kayode Olaleye
Greenhorn
Posts: 7
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone. I am a newbie in java and I'm happy to be here.
I have been on java applets and it's been fun but I'm stucked with painting a ladybug image on applet using "getImage ( getCodeBase(), "Images/ladybug.gif") to load the image. It runs but the appletviewer is blank.
My applets are not embedded in the web. I just type the codes in eclipse and click the 'run' button.
I think the problem is that java is not finding the image in the directory I specified. Please where am I supposed to save the ladybug image so that java can find it on my system whenever I supply the path. Thanks for your anticipated help.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Applets work differently inside of an IDE than outside of it. I suggest to create an HTML file with an APPLET tag, and then to run the applet outside of any IDE, either in a browser or suing appletviewer.

Also work through http://www.coderanch.com/how-to/java/CodeBarnLoadAGif
 
Kayode Olaleye
Greenhorn
Posts: 7
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf. The ladybug is now up on the applet. I'm on my way to making it move and fly. Here is what I eventually did. I simply moved the image to the same directory where LadyBug.class is stored and went back to the IDE to run the program. It displayed the image this time without writing an applet tag.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic