Example 13-1 is a
Swing component that displays a fractal image known as a "Julia set,"
pictured in Figure 13-1.
The image is fascinating, and the mathematics interesting, but the
real point of the example is the
) method, which demonstrates how to print the Julia set
using the Java 1.1 API and the Java 1.3 extensions to that API.
print( ) code is
straightforward: it sets some default attribute values, then displays
a dialog box to the user, to allow him to modify those attributes or
cancel the print request. The dialog box returns a
PrintJob object. The
print( ) method then obtains a
Graphics object from the
PrintJob. Next, it draws the Julia set to
Graphics object and, finally,
method to tell the printer that printing is done. These basic steps
are repeated in the next two examples as well: when studying the
examples of the Java 1.2 and Java 1.4 APIs, look for the code that
sets attributes, displays a dialog, and obtains the
Figure 13-1. A Julia set printed with the Java 1.1 API
java je3.gui.ShowBean je3.print.JuliaSet1
Example 13-1. JuliaSet1.java
package je3.print; import javax.swing.*; import java.awt.*; import java.awt.image.*; ...