Figure 1 shows a simple Java application with a JFrame. It contains a JTable found in Sun's Java tutorial on Swing components. If you click the first button, the contents of the table are added to a PDF using createGraphicsShapes() (the upper PDF in the screenshot).
If you click the second button, the table is added using createGraphics() (the lower PDF, using the standard Type 1 font Helvetica). Notice the subtle differences between the fonts used for both Figure 1. A Swing application with a JTable that is printed to PDF two different ways.
Click on thumbnail to view full-sized If you run this example, try changing the content of the JTable; the changes are reflected in the PDF. If you select a row, the background of the row is shown in a different color in the users on the mailing list. It's a simple text editor that allows you to write text in a JTextPane and print it to PDF.
Figure 2 shows this application in action.
Figure 2. A simple editor with a JTextPane that is drawn onto a PDF file.
Click on thumbnail to view full-sized image.
The code is a bit more complex than the JTable example. This example performs an affine transformation before the content of the JTextPane is painted:
