Solved

Problems loading images from a website.

Posted on 2004-09-12
6
207 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:kesea
  • 3
  • 2
6 Comments
 

Author Comment

by:kesea
ID: 12040214
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.
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 12040244
to access them from the jar use class.getResource() to get their URL.
0
 
LVL 16

Expert Comment

by:gnoon
ID: 12040666
>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.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:kesea
ID: 12047142
          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.
0
 

Author Comment

by:kesea
ID: 12047175
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.
0
 
LVL 92

Expert Comment

by:objects
ID: 12048715
no worries :)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question