7.12.1. Graphics Printing
In this section, we will tackle what is probably the most common printing situation: printing a 2D graphic. Of course, the graphic can contain text in various fonts or even consist entirely of text.
To generate a printout, you have to take care of these two tasks:
• Supply an object that implements the
• Start a print job
Printable interface has a single method:
int print(Graphics g, PageFormat format, int page)
That method is called whenever the print engine needs to have a page formatted for printing. Your code draws the text and the images to be printed onto the graphics context. The page format tells you the paper size and the print margins. The page number tells you which page to render. ...