JSVGCanvas can be used to display an SVG document from a file. Let’s see how this can be done.
For this purpose you need to create another simple Swing application. Its code is given in Listing 3.4. Again, it mainly consists of Swing components. You use a JSVGCanvas instance to display an SVG document, a JFileChooser to choose which document to display, and a JButton to invoke the File Chooser. Notice that, unlike in the previous versions of the application, here the canvas size is fixed.
package com.brainysoftware.batik; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; ...