Using pictures from the jar?  
Author Message
Dado





PostPosted: 2005-2-11 16:02:00 Top

java-programmer, Using pictures from the jar?

I create the jar with my classes, pictures and some txt files. The
application is starting just fine if picture folder is out of the jar.
If the folder picture is in the jar I don't see the pictures on my buttons
and everywhere.
How to solve that problem?
 
Tjerk Wolterink





PostPosted: 2005-2-11 17:58:00 Top

java-programmer >> Using pictures from the jar? Dado wrote:

>
> I create the jar with my classes, pictures and some txt files. The
> application is starting just fine if picture folder is out of the jar.
> If the folder picture is in the jar I don't see the pictures on my buttons
> and everywhere.
> How to solve that problem?

Its really easy, just within a class in your jar use:

java.net.URL url=this.getClass().getResource("/path/in/jar/image.gif");
Image image=(new ImageIcon(url)).getImage();