• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 17. Using SVG in Java Applicatio... > Displaying SVG in a Java Application

Displaying SVG in a Java Application

The features listed in the preceding section give you an idea of the power and versatility of the Toolkit. The capability to display SVG is certainly something that will have a place in many applications. Batik provides a component specifically for rendering SVG files in Swing applications: JSVGCanvas. This component is an extension of the standard Java JComponent class, which is the base for most visual components found in Swing. In use, the JSVGCanvas will be placed in a container in the same fashion as other Swing components, and then by using its loadSVGDocument() method, an SVG file can be loaded from a given URL or file. To demonstrate this usage, in Figure 17.1 we have created an SVG viewer application. We will look at the code shortly, but first here is a preview.

Figure 17.1. Our viewer in action.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint