• 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

Loading image on applet

 
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.
 
Rancher
Posts: 43016
76
  • 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 https://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.
 
We begin by testing your absorbancy by exposing you to this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic