Link to home
Start Free TrialLog in
Avatar of kesea
kesea

asked on

Problems loading images from a website.

Hi there, I am trying to display some images in a Japplet from a website.  I load them fine the first time, but if I refresh the JApplet, then some of the images don't reload, and when I display them I get a broken link.  Has anyone heard of this before?  Does anyone know if you can display an image from a .jar file in html?  If I could do that I am sure that would solve all my problems.  I am using:

           images_ac.append("<img src=\"" +mEmoticonData_t[i].mFileName_ac.toString()+">");

to load the images and putting it into a JEditPane which is in HTML mode.  Any suggestions?  Thanks.
Avatar of kesea
kesea

ASKER

Oops, the one thing I forgot to add is the mFileName_ac is a URL, it is http://www.website.com/picture/image.gif

If I could just include these picturs in my Jar and display them in HTML that would be great, i.e. putting picture/image.gif

Thanks.

kes.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>when I display them I get a broken link.
>....
>images_ac.append("<img src=\"" +mEmoticonData_t[i].mFileName_ac.toString()+">");

It means that mEmoticonData_t[i].mFileName_ac.toString() returns empty string or a wrong image path. You should check it first.

>I load them fine the first time, but if I refresh the JApplet, then some of the images don't reload
I've found this problem before, but my case is that when refresh the page, the applet got an error before display the image, so it wasn't reached.
Avatar of kesea

ASKER

          URL image = getClass().getResource(mEmoticonData_t[i].mImageName_ac.
                                              toString());
           images_ac.append("<img src=\"" +
//                            mEmoticonData_t[i].mURLName_ac.toString()+
                            image.getRef()+
                            "\" Width=\"1\" Height=\"1\">");

OK I tried loading it like this, but when I load it I get a null error?  I need to load it like this for putting images onto a list, but how can I put them into HTML?  I need to know how to get the proper reference to the image in the .jar file.  Thanks.
Avatar of kesea

ASKER

Oops that should have said, I have used this for loading the images into a list, but I need to get a refernce to the picture to put it in HTML, because I have that in a JEditorPane.  Thanks.
no worries :)