The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.
See Dev.java for updated tutorials taking advantage of the latest releases.
See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.
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 main classes and interfaces involved in printing are represented in the
java.awt.print
and
javax.print
packages (the last package allows you to get access to the printing services).
The basic printing operations are represented in the following sections:
Printable
interface and presents a basic printing program.javax.print
package.Swing
and refers to specific Swing
classes and interfaces.