Image - Problem

From: Yakman (nick_at_yakman.co.uk)
Date: 04/26/04


Date: Mon, 26 Apr 2004 15:41:15 +0100

I hava created an applet that uses JLabel and ImageIcon to place an array of
images in the middle of the applet, using the following:

productImages[1] = new ImageIcon(getImage(getDocumentBase(), "pic1.jpg"));

This works fine in the applet.

I then created a seperate class to load the applet using the "public static
void main(String args[])" method, but i could not run the main method unless
i changed the ImageIcon code to:

productImages[1] = new ImageIcon("pic1.jpg");

Again this now works fine.

My problem is that i then created an executable jar file containing the
images an class files.

When i run the jar file my applet runs ok but will not load the images
stored in the jar file. If i place the images in the same folder as the jar
file then they load ok.

How can i get to load the images that are in the jar file.

Many Thanks

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.657 / Virus Database: 422 - Release Date: 13/04/04


Relevant Pages

  • Re: Java Windows question..
    ... Remove most of the images, ... Move the applet from the homepage, onto a page where the user ... is warned to expect to 'wait a few moment' for it to load, or better, ... load it using webstart in a free floating window. ...
    (comp.lang.java.programmer)
  • Re: Image - Problem
    ... > images in the middle of the applet, ... > I then created a seperate class to load the applet using the "public static ... > My problem is that i then created an executable jar file containing the ... > images an class files. ...
    (comp.lang.java.help)
  • Re: Self-signed security certificates.. (oh, the evil)
    ... >> the user if server B is up and running. ... >> * You tried to solve this by writing an Applet on the page from ... Can you post the html you use to load the applet? ... > I tried to open the jar file with winzip and i got "failed to load ...
    (comp.lang.java.programmer)
  • Re: Cannot load image in applet after placing it in a package
    ... applet viewer is able to load the images using the same prefix. ... But when the browser loads the applet via the IIS server ...
    (comp.lang.java.programmer)
  • Re: Pages that wont display all the images....
    ... There really doesn't seem to any logic as to which images load an which will ... I can visit a page and a few will load and a few will not. ... > Free Software - Java Software for the desktop ... > Red X image displayed where the applet should be, ...
    (microsoft.public.windowsupdate)