Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Create an Icon from an SVG?

802237Dec 2 2004 — edited Dec 2 2004
I 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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 30 2004
Added on Dec 2 2004
1 comment
464 views