ImageIcons in jar files
1 posts in topic
Flat View  Flat View

Posted By:   Adam_Barclay
Posted On:   Sunday, May 12, 2002 02:41 AM


I'm new to java and even newer to using jar files for apps, so can somebody please explain to me how I would use an ImageIcon in a application. I wantto be able to put it on buttons, I have it working when the app is not packages in a jar file but then when it is in a jar file the image doesn't load, even with the images in the jar file tool. Any help would be appreciated, thanks :)

Re: ImageIcons in jar files

Posted By:   Kevin_Azijn  
Posted On:   Sunday, May 12, 2002 03:44 AM

Do it like this:

import java.net.*;

URL iconUrlFrame = ClassLoader.getSystemResource("images/earth.gif"); //or any other place where the pic is in the jarfile.

ImageIcon picFrame = new ImageIcon(iconUrlFrame);

Now you can see the pictures even when you make a jarfile.
About | Sitemap | Contact