|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
When you need more control over the individual pages in a print job,
you can use a pageable job instead of a printable job. The simplest way
to manage a pageable job is to use the Book class, which
represents a collection of pages.
TheSimpleBookprogram uses aBookto manage two page painters:PaintCoveris used for the cover page, andPaintContentis used for the content page. The cover page is printed in landscape mode, whereas the content page is printed in portrait mode.Once the
Bookis created, pages are added to it with theappendmethod. When you add a page to aBook, you need to specify thePrintableandPageFormatto use for that page.// In the program's job control code... // Get a PrinterJob PrinterJob job = PrinterJob.getPrinterJob(); // Create a landscape page format PageFormat landscape = job.defaultPage(); landscape.setOrientation(PageFormat.LANDSCAPE); // Set up a book Book bk = new Book(); bk.append(new PaintCover(), job.defaultPage()); bk.append(new PaintContent(), landscape); // Pass the book to the PrinterJob job.setPageable(bk);The
setPageablemethod is called on thePrinterJobto tell the printing system to use theBookto locate the appropriate rendering code.You can find the full program in
SimpleBook.java.
|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2004 Sun Microsystems, Inc. All rights reserved.