Create an Icon from an SVG?
802237Dec 2 2004 — edited Dec 2 2004I am trying to create an icon from an svg file, much the same way you can create one from a jpg or gif file by using new ImageIcon(URL).
For this I tried to use Batik JSVGCanvas but no luck, this code fragment works
JSVGCanvas svg = new JSVGCanvas();
svg.setURI("test.svg");
getContentPane().add(svg);
but this code fragment, to create an icon, does not
JSVGCanvas svg = new JSVGCanvas();
svg.setURI("test.svg");
BufferedImage image = new BufferedImage(256,256,ColorSpace.RGB);
Graphics2D g = image.createGraphics();
svg.paint(g);
ImageIcon icon = new ImageIcon(image);
g.dispose();
Has anyone had any luck creating a static Image or Icon from an SVG file?