Try this:
public static ImageIcon getImage(String imageKey) {
ImageIcon img = null;
URL imgURL = resource.getClass().getResource(imageKey);
if (null == imgURL)
throw new NullPointerException("Missing image for " + imageKey);
img = new ImageIcon(Toolkit.getDefaultToolkit().createImage(imgURL));
return img;
}
The resource instance is a do-nothing subclass of Object. I could have made
a simple call to this.getClass().getResource() but unfortunately my getImage
method needs to be static.
-----Original Message-----
From: Ajit Bhingarkar [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 02, 2001 2:57 PM
To: Ravi Prakash
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: how to get *.gif files from jar file
You need to use getResource() to get gifs ..
Ravi Prakash wrote:
>
> Hi,
>
> I am using applet and the classes are put in a jar file. In the jar
> file there are gif files.
> I have to display in the applet.
>
> i am using follwing syntax
>
> ImageIcon imageIcon = getImageIcon("cluster.gif");
> if (imageIcon != null) clusterImageJLabel.setIcon(imageIcon);
>
> I am not getting the image to be displayed in the applet.
>
> any suggestion please...
> raviprakash
>
> _______________________________________________
> Advanced-swing mailing list
> [EMAIL PROTECTED]
> http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing