0

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 :)

g123k
  • 3,748
  • 6
  • 42
  • 45

2 Answers2

1

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 Learning resources and tutorials for using the Java Batik Library

Community
  • 1
  • 1
marionmaiden
  • 3,250
  • 8
  • 33
  • 50
0

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);
g123k
  • 3,748
  • 6
  • 42
  • 45