Solved

Problems loading images from a website.

Posted on 2004-09-12
6
197 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 96
jar file executable 12 51
servlet example issue 6 38
Convert from a json string array to a Java object 3 28
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 …

806 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