1 18 19 package org.apache.batik.apps.jsvg; 20 21 import javax.swing.JFrame ; 22 import java.awt.BorderLayout ; 23 import java.awt.Dimension ; 24 import java.awt.event.WindowAdapter ; 25 import java.awt.event.WindowEvent ; 26 import org.apache.batik.swing.JSVGCanvas; 27 import org.apache.batik.swing.svg.SVGUserAgentGUIAdapter; 28 29 40 public class JSVG extends JFrame { 41 static int windowCount=0; 42 public JSVG(String url) { 43 super(url); 44 JSVGCanvas canvas = new JSVGCanvas(new SVGUserAgentGUIAdapter(this), 45 true, true) { 46 51 public void setMySize(Dimension d) { 52 setPreferredSize(d); 53 invalidate(); 54 JSVG.this.pack(); 55 } 56 }; 57 58 getContentPane().add(canvas, BorderLayout.CENTER); 59 canvas.setURI(url); 60 setVisible(true); 61 addWindowListener(new WindowAdapter () { 62 public void windowClosing(WindowEvent e) { 63 windowCount--; 64 if (windowCount == 0) 65 System.exit(0); 66 } 67 }); 68 windowCount++; 69 } 70 71 public static void main(String args[]) { 72 for (int i=0; i<args.length; i++) { 73 new JSVG(args[i]); 74 } 75 } 76 }; 77 | Popular Tags |