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].mFileN ame_ac.toS tring()+"> ");
to load the images and putting it into a JEditPane which is in HTML mode. Any suggestions? Thanks.
images_ac.append("<img src=\"" +mEmoticonData_t[i].mFileN
to load the images and putting it into a JEditPane which is in HTML mode. Any suggestions? Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>when I display them I get a broken link.
>....
>images_ac.append("<img src=\"" +mEmoticonData_t[i].mFileN ame_ac.toS tring()+"> ");
It means that mEmoticonData_t[i].mFileNa me_ac.toSt ring() 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.
>....
>images_ac.append("<img src=\"" +mEmoticonData_t[i].mFileN
It means that mEmoticonData_t[i].mFileNa
>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.
ASKER
URL image = getClass().getResource(mEm oticonData _t[i].mIma geName_ac.
toString());
images_ac.append("<img src=\"" +
// mEmoticonData_t[i].mURLNam e_ac.toStr ing()+
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.
toString());
images_ac.append("<img src=\"" +
// mEmoticonData_t[i].mURLNam
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.
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 :)
ASKER
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.