Java Platform 1.2
Beta 4

Class java.awt.print.PrinterJob

java.lang.Object
  |
  +--java.awt.print.PrinterJob

public abstract class PrinterJob
extends Object
The principal class that controls printing. An application calls methods int his class to set up a job, optionally to invoke a print dialog with the user, and then to print the pages of the job.


Method Summary
abstract  void cancel()
          If a print job is in progress, print() has been called but has not returned, then this signals that the job should be cancelled and the next chance.
 PageFormat defaultPage()
          A new PageFormat instance is created and then set with a default size and orientation.
abstract  PageFormat defaultPage(PageFormat page)
          The passed in PageFormat is cloned and the clone altered to describe a default page size and orientation.
abstract  int getCopies()
          Get the number of copies to be printed.
abstract  String getJobName()
          Get the name of the document to be printed.
static PrinterJob getPrinterJob()
          Creates and returns a PrinterJob.
abstract  String getUserName()
          Get the name of the printing user.
abstract  boolean isCancelled()
          Returns true is a print job is ongoing but will be cancelled and the next opportunity. false is returned otherwise.
abstract  PageFormat pageDialog(PageFormat page)
          Display a dialog to the user allowing the modification of a PageFormat instance.
abstract  void print()
          Prints a set of pages.
abstract  boolean printDialog()
          Presents the user a dialog for changing properties of the print job interactively.
abstract  void setCopies(int copies)
          Set the number of copies to be printed.
abstract  void setJobName(String jobName)
          Set the name of the document to be printed.
abstract  void setPageable(Pageable document)
          The pages in the document to be printed are held by the Pageable instance 'document'.
abstract  void setPrintable(Printable painter, PageFormat format)
          The pages in the document to be printed by this PrinterJob are drawn by the Printable object 'painter'.
abstract  void setPrintable(Printable painter)
          The pages in the document to be printed by this PrinterJob are drawn by the Printable object 'painter'.
abstract  PageFormat validatePage(PageFormat page)
          The passed in PageFormat is altered to be usable on the PrinterJob's current printer.
 
Methods inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
 

Method Detail

getPrinterJob

public static PrinterJob getPrinterJob()
Creates and returns a PrinterJob.

setPrintable

public abstract void setPrintable(Printable painter)
The pages in the document to be printed by this PrinterJob are drawn by the Printable object 'painter'. The PageFormat for each page is the default page format.
Parameters:
Printable - Called to render each page of the document.

setPrintable

public abstract void setPrintable(Printable painter,
                                  PageFormat format)
The pages in the document to be printed by this PrinterJob are drawn by the Printable object 'painter'. The PageFormat of each page is 'format'.
Parameters:
Printable - Called to render each page of the document.
PageFormat - The size and orientation of each page to be printed.

setPageable

public abstract void setPageable(Pageable document)
                          throws NullPointerException
The pages in the document to be printed are held by the Pageable instance 'document'. 'document' will be queried for the number of pages as well as the PageFormat and Printable for each page.
Parameters:
Pageable - The document to be printed. It may not be null.
Throws:
NullPointerException - the Pageable passed in was null.
See Also:
PageFormat, Printable

printDialog

public abstract boolean printDialog()
Presents the user a dialog for changing properties of the print job interactively.

pageDialog

public abstract PageFormat pageDialog(PageFormat page)
Display a dialog to the user allowing the modification of a PageFormat instance. The page argument is used to initialize controls in the page setup dialog. If the user cancels the dialog, then the method returns the original page object unmodified. If the user okays the dialog then the method returns a new PageFormat object with the indicated changes. In either case the original page object will not be modified.
Parameters:
page - the default PageFormat presented to the user for modification
Returns:
the original page object if the dialog is cancelled, or a new PageFormat object containing the format indicated by the user if the dialog is acknowledged
Since:
JDK1.2

defaultPage

public abstract PageFormat defaultPage(PageFormat page)
The passed in PageFormat is cloned and the clone altered to describe a default page size and orientation.
Parameters:
PageFormat - This object is cloned and the clone altered to describe a default PageFormat.

defaultPage

public PageFormat defaultPage()
A new PageFormat instance is created and then set with a default size and orientation.

validatePage

public abstract PageFormat validatePage(PageFormat page)
The passed in PageFormat is altered to be usable on the PrinterJob's current printer.
Parameters:
java.awt.print.PageFormat - this page description is cloned and then its settings are altered to be usuable for this printer job.
Returns:
java.awt.print.PageFormat a page description clones from the PageFormat parameter and altered to conform with this PrinterJob.

print

public abstract void print()
                    throws PrinterException
Prints a set of pages.
Throws:
PrinterException - an error in the print system caused the job to be aborted
See Also:
Book, Pageable, Printable

setCopies

public abstract void setCopies(int copies)
Set the number of copies to be printed.

getCopies

public abstract int getCopies()
Get the number of copies to be printed.

getUserName

public abstract String getUserName()
Get the name of the printing user.

setJobName

public abstract void setJobName(String jobName)
Set the name of the document to be printed. The document name can not be null.

getJobName

public abstract String getJobName()
Get the name of the document to be printed.

cancel

public abstract void cancel()
If a print job is in progress, print() has been called but has not returned, then this signals that the job should be cancelled and the next chance. If there is no print job in progress then this call does nothing.

isCancelled

public abstract boolean isCancelled()
Returns true is a print job is ongoing but will be cancelled and the next opportunity. false is returned otherwise.

Java Platform 1.2
Beta 4

Submit a bug or feature
Submit comments/suggestions about new javadoc look
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
This documentation was generated with a post-Beta4 version of Javadoc.