skip to main content
Programmer's documentation > The generic printing framework > Java print package and printing API > Using the PrinterJob class to print a component
 
Using the PrinterJob class to print a component
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().
1. Call method getPrinterJob() to create a printer job.
2. Call the setPrintable(Printable painter) method to specify the Printable object you have implemented.
3. To change the printer parameters you can open the Print dialog box by calling the printDialog() method.
4.
Print dialog box of Java SE
5. If you want to change the page format, open the Page Setup dialog box by calling the pageDialog() method.
6.
Page Setup Dialog Box of Java SE
7. 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.

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.