public class IlvPrintingController extends Object
IlvPrintingController
is the root object of the print framework.
It is designed to manage various printing tasks. It is the
root from which you can perform different print actions. You can invoke
different dialog boxes to change various printing parameters.
It is designed to manage the following objects:
IlvPrintableDocument
, which defines the contents to
be printed.IlvPrintPreviewDialog
, which can be used to preview the
contents to be printed.PrinterJob
, which is used to print the contents.
The IlvPrintingController
has two methods, printDialog()
and print()
, which you can use to change the printer
settings and to print the associated IlvPrintableDocument
.
IlvPrintableDocument
,
IlvPrintPreviewDialog
,
print(boolean)
Constructor and Description |
---|
IlvPrintingController(IlvPrintableDocument document)
Creates a
IlvPrintingController for the specified
IlvPrintableDocument . |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
Adds a listener to listen to the modification of all
properties
|
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener propertyChangeListener)
Adds a listener to listen to the modification of the specified
property.
|
void |
cleanPrintPreview(boolean dispose)
Cleans the Print Preview dialog box.
|
protected Window |
createPrintPreviewWindow(Window owner)
Creates the
IlvPrintPreviewDialog for previewing the associated
IlvPrintableDocument . |
protected IlvDocumentSetupDialog |
createSetupDialog(Window owner,
boolean printButton,
boolean printPreviewButton)
Creates the dialog box used to edit the parameters of a document.
|
protected void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Fires a 'PropertyChangeEvent' event for the specified property.
|
ComponentOrientation |
getComponentOrientation()
Returns the language-sensitive orientation of the dialogs managed by this
controller.
|
PageFormat |
getDefaultPageFormat()
Returns the default page format, chosen depending on the available
printers or - if no printer is available - depending on the current locale.
|
Paper |
getDefaultPaperFormat()
Returns the default paper dimensions, chosen depending on the available
printers or - if no printer is available - depending on the current locale.
|
IlvPrintableDocument |
getDocument()
Returns the
IlvPrintableDocument to be printed. |
PrinterJob |
getPreparedPrinterJob()
Returns the
PrinterJob used to print the contents. |
int |
getPreviewMode()
Returns the mode of the
IlvPrintPreviewPanel created by
createPrintPreviewWindow(java.awt.Window) . |
PrinterJob |
getPrinterJob()
Gets the
PrinterJob if it is already created. |
boolean |
isAutoDateUpdating()
Returns whether the date of the document is automatically updated.
|
void |
pageDialog()
This function shows a page format dialog box that allows users to change
the page format of the associated
IlvPrintableDocument . |
void |
print(boolean showPrintDialog)
Prints the document.
|
boolean |
printDialog()
Opens a dialog box for changes the setting
of the associated
PrinterJob . |
void |
printPreview(Window owner)
Opens a Print Preview dialog box.
|
void |
removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
Removes a listener so that it no longer listens to the
modification of the properties.
|
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener propertyChangeListener)
Removes a listener so that it no longer listens to the
modification of the specified property.
|
void |
setAutoDateUpdating(boolean enable)
Sets whether the date of the document is automatically updated.
|
void |
setComponentOrientation(ComponentOrientation o)
Sets the language-sensitive orientation of the dialogs managed by this
controller.
|
void |
setDocument(IlvPrintableDocument document)
Changes the
IlvPrintableDocument to be printed. |
void |
setLookAndFeel(UIManager.LookAndFeelInfo laf)
Updates the look & feel of the dialogs managed by this controller.
|
void |
setPreviewMode(int mode)
Changes the mode of the
IlvPrintPreviewPanel created by
createPrintPreviewWindow(java.awt.Window) . |
void |
setupDialog(Window owner,
boolean printButton,
boolean previewButton)
Opens the dialog box used to edit the parameters of a document.
|
public IlvPrintingController(IlvPrintableDocument document)
IlvPrintingController
for the specified
IlvPrintableDocument
.document
- The IlvPrintableDocument
that defines the contents
to be printed.public PrinterJob getPrinterJob()
PrinterJob
if it is already created. Otherwise,
a PrinterJob
will be created. This
PrinterJob
is used to change the printer settings and
to print the IlvPrintableDocument
.PrinterJob
used to print the contents.SecurityException
- in applet mode, if the user does not grant
access to the printerprint(boolean)
public PageFormat getDefaultPageFormat()
PageFormat
object.public Paper getDefaultPaperFormat()
Paper
object.public IlvPrintableDocument getDocument()
IlvPrintableDocument
to be printed.IlvPrintableDocument
that defines the contents
to be printed.public void setDocument(IlvPrintableDocument document)
IlvPrintableDocument
to be printed. This method refreshes
the preview of the document if it is visible.document
- The document that defines the contents to be printed.public boolean isAutoDateUpdating()
setAutoDateUpdating(boolean)
public void setAutoDateUpdating(boolean enable)
IlvHeaderFooter.getDateKey()
and
IlvHeaderFooter.getTimeKey()
) that gets replaced by the date or
time of the document (IlvPrintableDocument.getDate()
).
If the automatic update option is enabled, the date of the document
is updated every time the document is printed, hence the header or
footer contains the current time and date of the printing.
If the automatic update option is disabled, the date of the document
remains unchanged during printing, hence it does not indicate
the current time and date of the printing.
This option is enabled by default.isAutoDateUpdating()
public void printPreview(Window owner)
public void cleanPrintPreview(boolean dispose)
printPreview(java.awt.Window)
is called, a new dialog is created.
The method ensures first that the preview window is not showing.
The dispose
parameter specifies whether the preview window
is disposed as well. After disposing, it cannot be used anymore. If it is
not disposed, then it should be reused outside the printing controller
for some different purpose.dispose
- If true
, the preview window is disposed
and cannot be used anymore.
If false
, the preview window is not disposed,
only its reference inside the printing controller is cleaned.protected Window createPrintPreviewWindow(Window owner)
IlvPrintPreviewDialog
for previewing the associated
IlvPrintableDocument
. This method can be overridden by subclasses
if you want to customize the preview dialog. The preview mode
is defined by the method setPreviewMode(int)
.IlvPrintPreviewDialog
object.public int getPreviewMode()
IlvPrintPreviewPanel
created by
createPrintPreviewWindow(java.awt.Window)
. The mode can be one of
IlvPrintPreviewPanel.SINGLE_PAGE_MODE
or
IlvPrintPreviewPanel.CONTINUOUS_MODE
. The default mode is
IlvPrintPreviewPanel.SINGLE_PAGE_MODE
.printPreview(java.awt.Window)
public void setPreviewMode(int mode)
IlvPrintPreviewPanel
created by
createPrintPreviewWindow(java.awt.Window)
. The mode can be one of
IlvPrintPreviewPanel.SINGLE_PAGE_MODE
or
IlvPrintPreviewPanel.CONTINUOUS_MODE
. The method must be called before the
printPreview(java.awt.Window)
method is called.printPreview(java.awt.Window)
public void setupDialog(Window owner, boolean printButton, boolean previewButton)
owner
- The owner of the dialog.printButton
- Indicates if a button must be added to
the dialog to print the content of the document.previewButton
- Indicates if a button must be added
to the dialog to open the 'Print Preview' dialog.SecurityException
- in applet mode, if the user does not grant
access to the printerprotected IlvDocumentSetupDialog createSetupDialog(Window owner, boolean printButton, boolean printPreviewButton)
owner
- The owner of the dialog.printButton
- Indicates if a button must be added to
the dialog to print the content of the document.printPreviewButton
- Indicates if a button must be added
to the dialog to open the 'Print Preview' dialog.public PrinterJob getPreparedPrinterJob()
PrinterJob
used to print the contents.
The document will be prepared, and the PrinterJob
will be
notified about the number and size of the pages.PrinterJob
used to print the contents.SecurityException
- in applet mode, if the user does not grant
access to the printergetPrinterJob()
public boolean printDialog()
PrinterJob
. Call print()
to print the associated IlvPrintableDocument
.true
is the dialog was validated or false
SecurityException
- in applet mode, if the user does not grant
access to the printerprint(boolean)
,
getPrinterJob()
,
IlvPrintUtil.setNativePrintDialog(boolean)
public void pageDialog()
IlvPrintableDocument
. This
function uses the associated PrinterJob
and invokes
its pageDialog
method to open the page dialog. Note that
you should better use the setupDialog(java.awt.Window, boolean, boolean)
method that opens
a dialog that allows to change the page format and the header and footer.SecurityException
- in applet mode, if the user does not grant
access to the printerpublic void print(boolean showPrintDialog) throws PrinterException
print
method of the associated PrinterJob
.showPrintDialog
- When True
the dialog that allows to
choose a printer and set printer parameters will be shown before printing.PrinterException
- an error in the print system caused
the job to be aborted.getPrinterJob()
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
propertyName
- The name of the property.oldValue
- The old value of the property.newValue
- The new value of the property.public void addPropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
propertyName
- The name of the property.propertyChangeListener
- The listener.public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
propertyChangeListener
- The listener.public void removePropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
propertyName
- The name of the property.propertyChangeListener
- The listener.public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
propertyChangeListener
- The listener.public void setLookAndFeel(UIManager.LookAndFeelInfo laf)
laf
- The look & feel.public ComponentOrientation getComponentOrientation()
public void setComponentOrientation(ComponentOrientation o)
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.