PrinterJob class is the principal class that controls
printing. An application calls methods in this class to set up a job,
optionally to invoke a print dialog with the user, and then to print
the pages of the job.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public abstract void | |
| public abstract PageFormat | Returns: clone ofpage, altered to describe a default
PageFormat.the page)PageFormat to be cloned and alteredClones the |
| public PageFormat | Returns: aPageFormat set to a default size and
orientation.Creates a new |
| public abstract int | |
| public abstract String | Returns: the name of the document to be printed.Gets the name of the document to be printed. |
| public PageFormat | Returns: aPageFormat whose settings conform with
those of the current service and the specified attributes.a set of printing attributes, for example obtained
from calling printDialog. If attributes)attributes is null a default
PageFormat is returned.Calculates a |
| public static PrinterJob | Returns: a newPrinterJob.Creates and returns a |
| public PrintService | Returns: the service for this printer job.Returns the service (printer) for this printer job. |
| public abstract String | |
| public abstract boolean | Returns: true if the job in progress
is going to be cancelled; false otherwise.Returns |
| public static PrintService[] | Returns: a possibly empty array of 2D print services.A convenience method which looks up 2D print services. |
| public static StreamPrintServiceFactory[] | Returns: a possibly empty array of 2D stream print service factories.the required output format, or null to mean any format. mimeType)A convenience method which locates factories for stream print services which can image 2D graphics. |
| public abstract PageFormat | Returns: the originalpage object if the dialog
is cancelled; a new PageFormat object
containing the format indicated by the user if the
dialog is acknowledged.the default page)PageFormat presented to the
user for modificationDisplays a dialog that allows modification of a
|
| public PageFormat | Returns: a page format if the user does not cancel the dialog;null otherwise.on input is application supplied attributes,
on output the contents are updated to reflect user choices.
This parameter may not be null. attributes)A convenience method which displays a cross-platform page setup dialog. |
| public abstract void | |
| public void | print(PrintRequestAttributeSet
a set of attributes for the job attributes)Prints a set of pages using the settings in the attribute set. |
| public abstract boolean | Returns: true if the user does not cancel the dialog;
false otherwise.Presents a dialog to the user for changing the properties of the print job. |
| public boolean | Returns: true if the user does not cancel the dialog;
false otherwise.on input is application supplied attributes,
on output the contents are updated to reflect user choices.
This parameter may not be null. attributes)A convenience method which displays a cross-platform print dialog
for all services which are capable of printing 2D graphics using the
|
| public abstract void | |
| public abstract void | setJobName(String
the name of the document to be printed jobName)Sets the name of the document to be printed. |
| public abstract void | setPageable(Pageable
the pages to be printed. It can not be
document)null.Queries |
| public abstract void | setPrintable(Printable
the painter)Printable that renders each page of
the document.Calls |
| public abstract void | setPrintable(Printable
the painter, PageFormat Printable called to render
each page of the documentthe size and orientation of each page to
be printed format)Calls |
| public void | setPrintService(PrintService
a print service that supports 2D printing service)Associate this PrinterJob with a new PrintService. |
| public abstract PageFormat | Returns: aPageFormat that is cloned from
page and whose settings are changed
to conform with this PrinterJob.the page)PageFormat that is cloned and
whose settings are changed to be compatible with
the current printerReturns the clone of |
| PrinterJob | back to summary |
|---|---|
| public PrinterJob() A | |
| cancel | back to summary |
|---|---|
| public abstract void cancel() Cancels a print job that is in progress. If
| |
| defaultPage | back to summary |
|---|---|
| public abstract PageFormat defaultPage(PageFormat page) Clones the
| |
| defaultPage | back to summary |
|---|---|
| public PageFormat defaultPage() Creates a new
| |
| getCopies | back to summary |
|---|---|
| public abstract int getCopies() Gets the number of copies to be printed.
| |
| getJobName | back to summary |
|---|---|
| public abstract String getJobName() Gets the name of the document to be printed.
| |
| getPageFormat | back to summary |
|---|---|
| public PageFormat getPageFormat(PrintRequestAttributeSet attributes) Calculates a
Calling this method does not update the job.
It is useful for clients that have a set of attributes obtained from
| |
| getPrinterJob | back to summary |
|---|---|
| public static PrinterJob getPrinterJob() Creates and returns a
| |
| getPrintService | back to summary |
|---|---|
| public PrintService getPrintService() Returns the service (printer) for this printer job. Implementations of this class which do not support print services may return null. null will also be returned if no printers are available.
| |
| getUserName | back to summary |
|---|---|
| public abstract String getUserName() Gets the name of the printing user.
| |
| isCancelled | back to summary |
|---|---|
| public abstract boolean isCancelled() Returns
| |
| lookupPrintServices | back to summary |
|---|---|
| public static PrintService[] lookupPrintServices() A convenience method which looks up 2D print services.
Services returned from this method may be installed on
| |
| lookupStreamPrintServices | back to summary |
|---|---|
| public static StreamPrintServiceFactory[] lookupStreamPrintServices(String mimeType) A convenience method which locates factories for stream print services which can image 2D graphics. Sample usage :
Services returned from this method may be installed on
PrinterJob instances which support print services.
Calling this method is equivalent to calling
StreamPrintServiceFactory. and specifying a Pageable DocFlavor.
| |
| pageDialog | back to summary |
|---|---|
| public abstract PageFormat pageDialog(PageFormat page) throws HeadlessException Displays a dialog that allows modification of a
| |
| pageDialog | back to summary |
|---|---|
| public PageFormat pageDialog(PrintRequestAttributeSet attributes) throws HeadlessException A convenience method which displays a cross-platform page setup dialog. The choices available will reflect the print service currently set on this PrinterJob. The attributes parameter on input will reflect the client's required initial selections in the user dialog. Attributes which are not specified display using the default for the service. On return it will reflect the user's choices. Selections may be updated by the implementation to be consistent with the supported values for the currently selected print service. The return value will be a PageFormat equivalent to the selections in the PrintRequestAttributeSet. If the user cancels the dialog, the attributes will not reflect any changes made by the user, and the return value will be null.
| |
| back to summary | |
|---|---|
| public abstract void print() throws PrinterException Prints a set of pages.
| |
| back to summary | |
|---|---|
| public void print(PrintRequestAttributeSet attributes) throws PrinterException Prints a set of pages using the settings in the attribute set. The default implementation ignores the attribute set.
Note that some attributes may be set directly on the PrinterJob
by equivalent method calls, (for example), copies:
If a supported attribute-value is specified in this attribute set,
it will take precedence over the API settings for this print()
operation only.
The following behaviour is specified for PageFormat:
If a client uses the Printable interface, then the
These behaviours allow an application to directly pass the
user settings returned from
| |
| printDialog | back to summary |
|---|---|
| public abstract boolean printDialog() throws HeadlessException Presents a dialog to the user for changing the properties of
the print job.
This method will display a native dialog if a native print
service is selected, and user choice of printers will be restricted
to these native print services.
To present the cross platform print dialog for all services,
including native ones instead use
PrinterJob implementations which can use PrintService's will update the PrintService for this PrinterJob to reflect the new service selected by the user.
| |
| printDialog | back to summary |
|---|---|
| public boolean printDialog(PrintRequestAttributeSet attributes) throws HeadlessException A convenience method which displays a cross-platform print dialog
for all services which are capable of printing 2D graphics using the
The attributes parameter on input will reflect the applications required initial selections in the user dialog. Attributes not specified display using the default for the service. On return it will reflect the user's choices. Selections may be updated by the implementation to be consistent with the supported values for the currently selected print service. As the user scrolls to a new print service selection, the values copied are based on the settings for the previous service, together with any user changes. The values are not based on the original settings supplied by the client.
With the exception of selected printer, the PrinterJob state is
not updated to reflect the user's changes.
For the selections to affect a printer job, the attributes must
be specified in the call to the
| |
| setCopies | back to summary |
|---|---|
| public abstract void setCopies(int copies) Sets the number of copies to be printed.
| |
| setJobName | back to summary |
|---|---|
| public abstract void setJobName(String jobName) Sets the name of the document to be printed.
The document name can not be
| |
| setPageable | back to summary |
|---|---|
| public abstract void setPageable(Pageable document) throws NullPointerException Queries
| |
| setPrintable | back to summary |
|---|---|
| public abstract void setPrintable(Printable painter) Calls
| |
| setPrintable | back to summary |
|---|---|
| public abstract void setPrintable(Printable painter, PageFormat format) Calls
| |
| setPrintService | back to summary |
|---|---|
| public void setPrintService(PrintService service) throws PrinterException Associate this PrinterJob with a new PrintService.
This method is overridden by subclasses which support
specifying a Print Service.
Throws
| |
| validatePage | back to summary |
|---|---|
| public abstract PageFormat validatePage(PageFormat page) Returns the clone of
| |