Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 18 19 package org.test; 20 21 import java.awt.Dimension ; 22 import java.io.File ; 23 import java.net.URL ; 24 import java.net.MalformedURLException ; 25 import javax.swing.JFrame ; 26 import javax.swing.WindowConstants ; 27 28 import org.apache.batik.swing.*; 29 30 41 public class ScrollExample 42 { 43 44 45 public static void main(String args[]) 46 { 47 if(args.length != 1) 48 { 49 System.out.println("No or multiple SVG files were specified."); 50 System.out.println("Usage: ScrollExample svgFileName"); 51 System.exit(1); 52 } 53 54 File file = new File (args[0]); 56 if(!file.exists()) 57 { 58 System.out.println("File "+file+" does not exist!"); 59 System.exit(1); 60 } 61 62 try 63 { 64 new ScrollExample(file.toURL()); 65 } 66 catch(MalformedURLException e) 67 { 68 System.out.println("Cannot convert file to a valid URL..."); 69 System.out.println(e); 70 System.exit(1); 71 } 72 73 } 75 76 77 private ScrollExample(URL url) 78 { 79 JFrame frame = new JFrame ("ScrollExample: "+url.getFile()); 80 frame.setResizable(true); 81 frame.setSize(new Dimension (500,500)); 82 frame.addWindowListener(new java.awt.event.WindowAdapter () { 83 public void windowClosing 84 (java.awt.event.WindowEvent e) { 85 System.exit(0); 86 } 87 }); 88 89 91 JSVGCanvas canvas = new JSVGCanvas(); 92 JSVGScrollPane scroller = new JSVGScrollPane(canvas); 93 canvas.setURI(url.toString()); 94 95 frame.getContentPane().add(scroller); 96 frame.setVisible(true); 97 } 99 100 101 102 } 104
| Popular Tags
|