Solved

Problems loading images from a website.

Posted on 2004-09-12
6
185 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
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…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

746 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now