O'Reilly logo

Java™ Drawing with Apache Batik: A Tutorial by Alexander Kolesnikov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Saving the Generated Document

Like everything else you’ve seen so far, saving an SVG document can be done in Batik in just a few lines of code. In this section, you add this functionality. You use a dialog to enter the file name and choose the save location. You use a button to open the dialog. The easiest way to achieve this is by using Swing components JFileChooser and JButton.

Once you add this function, you get a new version of the application. Let’s call this new version Creator Plus 2. Before jumping into coding, I’d like to show you how it looks first. Figure 3.7 shows how it should look like. Notice the Save button is added to the bottom of the window.

Figure 3.7. Saving the created content

With Creator Plus 2, you can save your work ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required