Java Reference
In-Depth Information
• WHAT YOU LEARNED IN THIS CHAPTER
TOPIC CONCEPT
Serialization You can implement the ability to write your model object to a file and read it back by making it serial-
izable.
The
JFileChooser
Class
The JFileChooser class provides a generalized way for displaying a dialog to enable a file to be
chosen.
Filtering a File
List
You can limit the files that are displayed in a file chooser dialog by implementing a file filter. You can
define you own file filter by subclassing the FileFilter class.
Printing
You initiate a printing operation by creating a PrinterJob object. This object encapsulates the inter-
face to your printer and is used to manage the printing process.
Printers
A PrintService object encapsulates a printer and its capabilities.
Page Format-
ting
A PageFormat object defines the format for a page, and methods for this object provide information on
the paper size and orientation, and the printable area on the page.
Paper An object of type Paper defines the physical characteristics of a sheet of paper for the printer.
Print Dialogs You can display a print dialog by calling the printDialog() method for a PrinterJob object. The no-
argument version of printDialog() displays the native print dialog, whereas the version accepting a
single argument of type PrintRequestAttributeSet displays a Java print dialog.
Printing a
Page
Printing a page is always done by an object of a class that implements the Printable interface. You
print a page by calling methods for the Graphics object passed to the print() method in the Print-
able interface by the PrinterJob object.
Printing Mul-
tiple Pages
You can manage multipage print jobs by implementing the Pageable interface in a class. This enables
you to use different PageFormat objects to print different pages.
The Book
Class
A Book object can encapsulate a series of pages to be printed. Each Printable object that is appended
to a book prints one or more pages in a given format.
Search WWH ::




Custom Search