unbbayes.controller
Class PrintMonitor

java.lang.Object
  extended by unbbayes.controller.PrintMonitor
All Implemented Interfaces:
Pageable

public class PrintMonitor
extends Object
implements Pageable

Creating an instance of this class and printing it allows it to add a status dialog during printing. The print requests are simply delegated to the Pageable that actually contains the data to be printed, but by intercepting those calls, we can update the page number displayed in our dialog so that it indicates which page is currently being displayed.


Field Summary
protected  JOptionPane optionPane
           
protected  Pageable pageable
           
protected  PrinterJob printerJob
           
protected  JDialog statusDialog
           
 
Fields inherited from interface java.awt.print.Pageable
UNKNOWN_NUMBER_OF_PAGES
 
Constructor Summary
PrintMonitor(Pageable p)
           
 
Method Summary
 int getNumberOfPages()
           
 PageFormat getPageFormat(int index)
           
 Printable getPrintable(int index)
           
 void performPrint(boolean showDialog)
          Create a new thread and have it call the print() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

printerJob

protected PrinterJob printerJob

pageable

protected Pageable pageable

optionPane

protected JOptionPane optionPane

statusDialog

protected JDialog statusDialog
Constructor Detail

PrintMonitor

public PrintMonitor(Pageable p)
Method Detail

performPrint

public void performPrint(boolean showDialog)
                  throws PrinterException
Create a new thread and have it call the print() method. This ensures that the AWT event thread will be able to handle the Cancel button if it is pressed, and can cancel the print job.

Throws:
PrinterException

getNumberOfPages

public int getNumberOfPages()
Specified by:
getNumberOfPages in interface Pageable

getPrintable

public Printable getPrintable(int index)
Specified by:
getPrintable in interface Pageable

getPageFormat

public PageFormat getPageFormat(int index)
Specified by:
getPageFormat in interface Pageable


Copyright © 2001-2010 University of Brasilia - UnB. All Rights Reserved.