1 package org.simantics.scenegraph.tests;
9 import com.kitfox.svg.*;
10 import com.kitfox.svg.app.beans.*;
13 class IconPanel extends JPanel
15 public static final long serialVersionUID = 0;
20 setPreferredSize(new Dimension(400, 400));
23 public void load() throws IOException
25 InputStream is = getClass().getResourceAsStream("test_caption_frame.svg");
26 URI uri = SVGCache.getSVGUniverse().loadSVG(is, "myImage");
27 System.out.println("loaded: " + uri);
32 public void paintComponent(Graphics g)
34 Graphics2D g2d = (Graphics2D) g;
35 final int width = getWidth();
36 final int height = getHeight();
38 g.setColor(getBackground());
39 g.fillRect(0, 0, width, height);
41 icon.paintIcon(this, g, width/20, height/20);
49 public class SVGIODemoFrame extends javax.swing.JFrame
51 public static final long serialVersionUID = 0;
53 IconPanel panel = new IconPanel();
55 /** Creates new form SVGIconDemo */
56 public SVGIODemoFrame()
61 } catch (IOException e) {
65 this.getContentPane().add(panel, BorderLayout.CENTER);
70 /** This method is called from within the constructor to
71 * initialize the form.
72 * WARNING: Do NOT modify this code. The content of this method is
73 * always regenerated by the Form Editor.
75 private void initComponents()
78 setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
79 setLayout(new java.awt.BorderLayout());
83 public static void main(String args[])
85 java.awt.EventQueue.invokeLater(new Runnable()
89 new SVGIODemoFrame().setVisible(true);