This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Eclipse applet viewer & images Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Eclipse applet viewer & images" Watch "Eclipse applet viewer & images" New topic

Eclipse applet viewer & images

David Herron

Joined: Jul 27, 2011
Posts: 12
I am looking for some help with Eclipse. I can not get my images to show in my applet viewer. If I embed the applet in an html file, they display just fine. My file names are accurate (I've checked a gazillion times), and the paths are correct. I am trying something more complicated than this, but even this code does not display. Text shows up also. Is there settings somewhere I need to adjust?? Please help. I'm going nuts!

Rob Spoor

Joined: Oct 27, 2005
Posts: 20132

I've never tried to run an applet from Eclipse, so I can't help you with that.

I would like to point out that it's not wise to load your image in the paint method. That method may be called several times a second, and you really don't want to load the same image over and over again. It's better to do that in the init() method:
Now the image is only loaded once, when the applet is initialized.

How To Ask Questions How To Answer Questions
David Herron

Joined: Jul 27, 2011
Posts: 12
OK.. Thanks a lot. The book our class has us using actually does this. Maybe it was for the sake of a simple example. Still, they should point this out. Thanks for the advise!
Andrew Thompson
Ranch Hand

Joined: Aug 05, 2010
Posts: 77
David Herron wrote:..The book our class has us using actually does this...

I've said before that any book that rushes into teaching applets is suspect. But this one is far worse, in that the authors have demonstrated they are clueless - we should never be loading images in the paint method. Use that book for something useful like a door stop or paper weight, and get a good Java text to replace it.

Andrew Thompson
David Herron

Joined: Jul 27, 2011
Posts: 12
At least I am only renting it! I am on the last assignment for this class, and I'm giving it the boot ASAP! I recently attained a new Java book for my library and it seems much better. And BTW.. I solved my initial problem, which was I had been putting my images into the src file when I needed to be placing them into the bin folder (where the class file is located).
I agree. Here's the link:
subject: Eclipse applet viewer & images
It's not a secret anymore!