APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.swing

public Class PrintingStatus

extends Object
Class Inheritance
Imports
javax.swing.*, java.awt.*, java.awt.event.ActionEvent, .WindowAdapter, .WindowEvent, java.awt.print.PageFormat, .Printable, .PrinterException, .PrinterJob, java.text.MessageFormat, java.util.concurrent.atomic.AtomicBoolean, java.lang.reflect.InvocationTargetException

The PrintingStatus provides a dialog that displays progress of the printing job and provides a way to abort it

Methods of these class are thread safe, although most Swing methods are not. Please see Concurrency in Swing for more information.

Author
Alexander Potochkin
Since
1.6

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final Action
private JButton
private JDialog
private final WindowAdapter
private final AtomicBoolean
private final PrinterJob
private final Component
private MessageFormat
private JLabel

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public Printable

Returns:

printable which is used to track the current page being printed in this PrintingStatus
createNotificationPrintable
(Printable
to be used to create notification printable
printable
)

Returns printable which is used to track the current page being printed in this PrintingStatus

public static PrintingStatus

Returns:

a PrintingStatus object
createPrintingStatus
(Component
a Component object to be used as parent component for PrintingStatus dialog
parent
,
PrinterJob
a PrinterJob object to be cancelled using this PrintingStatus dialog
job
)

Creates PrintingStatus instance

public void
dispose()

Disposes modal PrintingStatus dialog

private void
disposeOnEDT()

The EDT part of the dispose method.

pack-priv static int
getInt(Object key, int defaultValue)

Duplicated from UIManager to make it visible

private void
init()

public boolean

Returns:

whether the printing was aborted using this PrintingStatus
isAborted
()

Returns whether the printing was aborted using this PrintingStatus

public void
showModal(final boolean
true this dialog should be modal; false otherwise.
isModal
)

Shows PrintingStatus dialog.

private void
showModalOnEDT(boolean isModal)

The EDT part of the showModal method.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

abortActionback to summary
private final Action abortAction
abortButtonback to summary
private JButton abortButton
abortDialogback to summary
private JDialog abortDialog
closeListenerback to summary
private final WindowAdapter closeListener
isAbortedback to summary
private final AtomicBoolean isAborted
jobback to summary
private final PrinterJob job
parentback to summary
private final Component parent
statusFormatback to summary
private MessageFormat statusFormat
statusLabelback to summary
private JLabel statusLabel

Constructor Detail

PrintingStatusback to summary
protected PrintingStatus(Component parent, PrinterJob job)

Method Detail

createNotificationPrintableback to summary
public Printable createNotificationPrintable(Printable printable)

Returns printable which is used to track the current page being printed in this PrintingStatus

Parameters
printable:Printable

to be used to create notification printable

Returns:Printable

printable which is used to track the current page being printed in this PrintingStatus

Exceptions
NullPointerException:
if printable is null
createPrintingStatusback to summary
public static PrintingStatus createPrintingStatus(Component parent, PrinterJob job)

Creates PrintingStatus instance

Parameters
parent:Component

a Component object to be used as parent component for PrintingStatus dialog

job:PrinterJob

a PrinterJob object to be cancelled using this PrintingStatus dialog

Returns:PrintingStatus

a PrintingStatus object

disposeback to summary
public void dispose()

Disposes modal PrintingStatus dialog

See Also
showModal(boolean)
disposeOnEDTback to summary
private void disposeOnEDT()

The EDT part of the dispose method. This method is to be called on the EDT only.

getIntback to summary
pack-priv static int getInt(Object key, int defaultValue)

Duplicated from UIManager to make it visible

initback to summary
private void init()
isAbortedback to summary
public boolean isAborted()

Returns whether the printing was aborted using this PrintingStatus

Returns:boolean

whether the printing was aborted using this PrintingStatus

showModalback to summary
public void showModal(final boolean isModal)

Shows PrintingStatus dialog. if dialog is modal this method returns only after dispose() was called otherwise returns immediately

Parameters
isModal:boolean

true this dialog should be modal; false otherwise.

See Also
dispose
showModalOnEDTback to summary
private void showModalOnEDT(boolean isModal)

The EDT part of the showModal method. This method is to be called on the EDT only.

sun.swing back to summary

private Class PrintingStatus.NotificationPrintable

extends Object
implements Printable
Class Inheritance
All Implemented Interfaces
java.awt.print.Printable

Field Summary

Modifier and TypeField and Description
private final Printable

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
print(final Graphics graphics, final PageFormat pageFormat, final int pageIndex)

Implements java.awt.print.Printable.print.

Prints the page at the specified index into the specified Graphics context in the specified format.

private void
updateStatusOnEDT(int pageIndex)

The EDT part of the print method.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

printDelegateeback to summary
private final Printable printDelegatee

Constructor Detail

NotificationPrintableback to summary
public NotificationPrintable(Printable delegatee)

Method Detail

printback to summary
public int print(final Graphics graphics, final PageFormat pageFormat, final int pageIndex) throws PrinterException

Implements java.awt.print.Printable.print.

Doc from java.awt.print.Printable.print.

Prints the page at the specified index into the specified Graphics context in the specified format. A PrinterJob calls the Printable interface to request that a page be rendered into the context specified by graphics. The format of the page to be drawn is specified by pageFormat. The zero based index of the requested page is specified by pageIndex. If the requested page does not exist then this method returns NO_SUCH_PAGE; otherwise PAGE_EXISTS is returned. The Graphics class or subclass implements the PrinterGraphics interface to provide additional information. If the Printable object aborts the print job then it throws a PrinterException.

Exceptions
PrinterException:
thrown when the print job is terminated.
updateStatusOnEDTback to summary
private void updateStatusOnEDT(int pageIndex)

The EDT part of the print method. This method is to be called on the EDT only.