Since the Java 2D API enables you to draw on any surface, a natural extension of that is the ability to print Java 2D graphics. A printer can be considered a graphics device just like a display.
The Java 2D printing API is not limited to printing graphics. It enables you to print the content of an application's user interface as well. Content can be printed by sending raw data to the printer under the formatting control of the Java 2D printing API, or by using the Java 2D Graphics API.
In this lesson you will explore the printer and job control functions of the Java 2D printing API which are complements to the rendering elements. You will learn how to look up printers configured on the system or network and discover information about these printers such as the paper sizes it supports, and selecting these attributes for printing, and user dialogs.
The basic printing operations are represented in the following sections:
A Basic Printing Program – this section describes the
Printableinterface and presents a basic printing program.
Using Print Setup Dialogs– this sections explains how to display the Print Setup Dialog.
Printing a Multiple Page Document – this section explains how to use pagination for printing a multiple page document.
Working with Print Services and Attributes ndash; this section teaches you about print services, how to specify the print data format, and how to create print job using the
Printing the Contents of a User Interface – this section explains how to print the contents of a window or a frame.
Printing Support in Swing Components ndash; this section provides a brief description of the related printing functionality in
Swingand refers to specific
Swingclasses and interfaces.