
of the applet or component. Note, however, that built-in AWT components are
drawn by the native GUI system, rather than a
paint() method, and may not
print correctly.
4. When you are done drawing the page, you call the
dispose() method of the
Graphics object to send that page description to the printer. If you need to
print another page, you can call the
getGraphics() method of the PrintJob
again to obtain a new Graphics object for the next page and repeat the pro-
cess of drawing and calling
dispose().
5. When you have printed all of your pages, you end the print job itself by call-
ing the
end() method of the PrintJob object.
With the Java 1.1 printing API, the coordinate system of the printer is very much
like the coordinate system used when drawing on-screen. The origin is at the top
left, X coordinates run from left to right, and Y coordinates run from the top to the
bottom of the page. The coordinate system uses a resolution of 72 points per inch,
which is a typical resolution for monitors as well. Most printers support much
higher resolutions than this, however, and they use that extra resolution when
printing text, for example. However, because the Java 1.1
Graphics object does
not allow floating-point coordinates, all graphics must be positioned exactly at
integer positions.
Pr inting in Java 1.2
Java 1.2 introduces a more complete printing API. As in Java 1.1, printing is done
by calling methods ...