Image load error

M

mcampo84

Hi all,

I'm currently trying to convert a java application based on Piccolo
(http://www.cs.umd.edu/hcil/piccolo/) to an applet - it's pretty much a
family tree that shows pictures along with the names. I had it running
fine as a standalone application, but the imbedded applet conversion is
giving me a few problems. Originally, I was creating some PImage nodes
with the PImage(String) constructor and that was working fine. With
the applet, however, I've had to move the image files to a folder I
named "images" and included it in the src folder that NetBeans provides
me - so now the images are wrapped up in the jar. I modified my code
so that it looks like this:

private final ClassLoader cl = getClass().getClassLoader();
private final String PERSON_ICON = String.valueOf(
cl.etResource( "images/person.gif"));
private final Image PERSON_IMAGE =
Toolkit.getDefaultToolkit().getImage(PERSON_ICON);
.
.
.
entityImage = new PImage(PERSON_IMAGE);

The program runs, but I get an error message that says "media tracker
errored image load" for every node I try to create.

Any suggestions?

-mc
 
M

mcampo84

With enough time spent thinking that no one will help you, a solution
presents itself! I wound up getting it to work, so for all those out
there who might have the same problem, there is the correct code:

private final ClassLoader cl = getClass().getClassLoader();
private final String PERSON_ICON = "images/person.gif";
private final Image PERSON_IMAGE =
Toolkit.getDefaultToolkit().getImage(
cl.getResource(PERSON_ICON));
.
.
.
entityImage = new PImage(PERSON_IMAGE);

-mc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top