|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
You can allow the user to specify page characteristics, such as the paper size and orientation, by displaying a Page Setup dialog. The page information is stored in aPageFormatobject. Like the Print dialog, the Page Setup dialog is displayed by calling a method on thePrinterJobobject,pageDialog.The Page Setup dialog is initialized by using the
PageFormatpassed to thepageDialogmethod. If the user clicks the OK button in the dialog, thePageFormatis cloned, altered to reflect the user's selections, and then returned. If the user cancels the dialog,pageDialogreturns the original, unalteredPageFormat.
ShapesPrintcould easily be modified to display a Page Setup dialog by adding a call topageDialogafter you get thePrinterJob.// Get a PrinterJob PrinterJob job = PrinterJob.getPrinterJob(); // Ask user for page format (e.g., portrait/landscape) PageFormat pf = job.pageDialog(job.defaultPage());
|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2004 Sun Microsystems, Inc. All rights reserved.