• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Loading image on applet

 
Greenhorn
Posts: 7
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic