Advanced Features > The Generic Printing Framework > Java Print Package and Printing API > The PrinterJob Class

The PrinterJob class is the root of the java.awt.print package. To print your component, you must create a PrinterJob object. The PrinterJob class has a static method called getPrinterJob(), which is used to create a concrete printer job.

To print your component, call the setPrintable(Printable painter) method to specify the Printable object you have implemented. To change the printer parameters you can open a dialog box by calling the printDialog() method.

images/print-printdialog.gif

Figure 3.1 Print Dialog Box of Java SE

You can also open a dialog box to change the page format by calling the pageDialog() method.

images/print-pagedialog.gif

Figure 3.2 Page Setup Dialog Box of Java SE

Finally, to send the printing job to the selected printers, call the print() method of the printer job. See the documentation of the PrinterJob class for more information.