com.wildcrest.j2printerworks
Class PrintingEventHandler

java.lang.Object
  extended bycom.wildcrest.j2printerworks.PrintingEventHandler
All Implemented Interfaces:
java.util.EventListener, java.beans.PropertyChangeListener

public class PrintingEventHandler
extends java.lang.Object
implements java.beans.PropertyChangeListener

Convenience class for easy handling of J2PrinterWorks print progress events including beginning and end of printing, OK or cancel of print dialog, OK or cancel of page setup dialog, start and end of each printed page, and open and close of print preview dialog. To use, just call printer.addPropertyChangeListener(new MyPrintingEventHandler()) where MyPrintingEventHandler extends PrintingEventHandler and overrides any methods of interest.

All methods (except propertyChange and exceptionThrown) have empty implementations, so to process any desired event(s), you override the corresponding method and wait for it to be called. The exceptionThrown method has a default implementation of e.printStackTrace() and can be overridden if you wish to have error fail silently of if you wish to respond to such errors yourself. The propertyChange method is the central event handling method of PrintingEventHandler that listens to all events and calls the other PrintingEventHandler methods when appropriate and should generally be left unchanged.


Constructor Summary
PrintingEventHandler()
          PrintingEventHandler class constructor.
 
Method Summary
 void exceptionThrown(java.lang.Exception e)
          Called once when an Exception (usually a java.awt.print.PrinterException) occurs during printing, default implementation is e.printStackTrace()
 void pageDone(int pageNumber)
          Called each time a page completes printing (pageNumber 1...n)
 void pageSetupDialogCanceled()
          Called once when user presses "Cancel" in page setup dialog
 void pageSetupDialogOK()
          Called once when user presses "OK" in page setup dialog
 void pageStart(int pageNumber)
          Called each time a page begins printing (pageNumber 1...n)
 void printDialogCanceled()
          Called once when user presses "Cancel" in print dialog
 void printDialogOK()
          Called once when user presses "OK" in print dialog
 void printingDone()
          Called once when printing completes
 void printingStart()
          Called once when printing begins
 void printPreviewDone()
          Called once when print preview dialog is closed
 void printPreviewStart()
          Called once when print preview dialog opens
 void propertyChange(java.beans.PropertyChangeEvent evt)
          Low-level printer event property change method (do not modify)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrintingEventHandler

public PrintingEventHandler()
PrintingEventHandler class constructor. Subclass and override desired methods to handle print progress events.

Method Detail

printingStart

public void printingStart()
Called once when printing begins


printingDone

public void printingDone()
Called once when printing completes


printDialogOK

public void printDialogOK()
Called once when user presses "OK" in print dialog


printDialogCanceled

public void printDialogCanceled()
Called once when user presses "Cancel" in print dialog


pageSetupDialogOK

public void pageSetupDialogOK()
Called once when user presses "OK" in page setup dialog


pageSetupDialogCanceled

public void pageSetupDialogCanceled()
Called once when user presses "Cancel" in page setup dialog


pageStart

public void pageStart(int pageNumber)
Called each time a page begins printing (pageNumber 1...n)


pageDone

public void pageDone(int pageNumber)
Called each time a page completes printing (pageNumber 1...n)


printPreviewStart

public void printPreviewStart()
Called once when print preview dialog opens


printPreviewDone

public void printPreviewDone()
Called once when print preview dialog is closed


exceptionThrown

public void exceptionThrown(java.lang.Exception e)
Called once when an Exception (usually a java.awt.print.PrinterException) occurs during printing, default implementation is e.printStackTrace()


propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Low-level printer event property change method (do not modify)

Specified by:
propertyChange in interface java.beans.PropertyChangeListener