views:

98

answers:

2

Hello,

I have a transparent SVG file. I would like to use it as the icon of a JLabel, via setIcon().

I use Batik for SVG, but I don't know how to do this. Can you help me ?

Thanks :)

A: 

I suggest to you take a look at Batik project

http://xmlgraphics.apache.org/batik/

It's a library for use SVG images in Java apps.

And this question have some help about using Batik library http://stackoverflow.com/questions/1558852/learning-resources-and-tutorials-for-using-the-java-batik-library

marionmaiden
A: 

I have found the solution :

SVG r = new SVG(new File(*something*).toURI().toString());
BufferedImage img = r.createBufferedImage();
this.enabledIcon = new ImageIcon(img);
label.setIcon(img);