The printable interface
The Printable interface is the most important interface of the java.awt.print package. To make a UI component printable, you need to implement this interface, which has a single method:
public int print(Graphics graphics,
PageFormat pageFormat,
int pageIndex) throws PrinterException
This method is called by the Java™ printing system when it sends the printing instructions to a printer. To print your component, you need to call the drawing methods of the Graphics object passed as the first argument.
While printing your component, you can get more information on the type of paper being currently used from the second and the third arguments of this method.
After implementing the Printable interface, you need to create a PrinterJob object to print your component.
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.