How to set a transparent Icon from a transparent SVG file
I 开发者_StackOverflow社区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 :)
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
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);
精彩评论