com.wildcrest.j2printerworks
Class J2Printer

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended bycom.wildcrest.j2printerworks.J2Printer
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
J2Printer14, J2PrinterWebStart

public class J2Printer
extends javax.swing.JComponent

A Java 2 component for printing one or more Pageables as a single document.

Supports headers & footers, date & page numbering, margins, orientation, scale, paper size, background printing thread, printing progress events, Print Preview dialog, Page Setup dialog, Pageable & Book support, print job name control, number of copies, n-up printing, print to HTML, printer discovery and selection (1.4 or later), print request attributes (1.4 or later), cross-platform dialogs (1.4 or later), and print to Postscript (1.4 or later).

Programs using the J2Printer class can build and run on all JDKs 1.2 or later.
Use the J2Printer14 subclass to access the JDK 1.4 printing features, but you must build and run under JDK 1.4 or later.

(C) Copyright 2009, Wildcrest Associates (http://www.wildcrest.com). All rights reserved.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int BEFORE
          Specifies that print preview dialog should be closed bringing up print dialog.
static int BOTTOM
          Specifies vertical alignment to be bottom justified within the available space.
static int BOX
          Specifies that a box is drawn around the header or the footer.
static int CENTER
          Specifies horizontal or vertical alignment to be centered within the available space.
static int FIRST
          Denotes values for page 1.
static int GLOBAL
          Indicates that the "global" (overall, default, J2Printer) values are to be used for margins, header/footer style, orientation, etc., as opposed to the "local" (individual Pageable) values.
static int LANDSCAPE
          Specifies that the page orientation is landscape (content rotated 90 degrees counter-clockwise relative to portrait).
static int LEFT
          Specifies horizontal alignment to be left justified within the available space.
static int LINE
          Specifies that a line is drawn below the header or above the footer.
static int NEVER
          Specifies that print preview dialog should be kept open until closed manually by user.
static int NONE
          Specifies that no additional line or box is drawn for the header or footer.
static int OUTLINE
          Specifies that an outline is drawn around the page image returned by getPageImage.
static int PLAIN
          Specifies that no outline is drawn around the page image returned by getPageImage.
static int PORTRAIT
          Specifies that the page orientation is portrait.
static int PPI72
          A constant specifying the standard printing resolution of 72 dots ("points") per inch.
protected static java.awt.print.PrinterJob printerJob
           
protected static java.awt.print.PrinterJob printerJobSeparateThread
           
static int REST
          Denotes values for pages 2...n.
static int REVERSE_LANDSCAPE
          Specifies that the page orientation is reverse landscape (landscape rotated 180 degrees).
static int RIGHT
          Specifies horizontal alignment to be right justified within the available space.
static int SHADOW
          Specifies that an outline and a drop shadow are drawn around the page image returned by getPageImage.
static int TOP
          Specifies vertical alignment to be top justified within the available space.
static int WAIT
          Specifies that print preview dialog should be closed after print dialog comes up (or after printing begins if not using print dialog).
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
J2Printer()
          Construct a J2Printer object with no serial number, a default printer, and an empty Pageable.
J2Printer(java.awt.print.PrinterJob printerJob)
          Construct a J2Printer object with no serial number, a given PrinterJob, and an empty Pageable.
J2Printer(java.lang.String serialNum)
          Construct a J2Printer object with given serial number, default printer, and empty Pageable.
J2Printer(java.lang.String serialNum, java.awt.print.PrinterJob printerJob)
          Construct a J2Printer object with given serial number and PrinterJob, and empty Pageable.
 
Method Summary
 void addPageable(java.awt.print.Pageable pageable)
          Add specified Pageable to end of this J2Printer's current Pageables list.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a PropertyChangeListener for this component
 void cancelPrinting()
          Cancel the current printing job.
 void changePrintPreviewLookAndFeel(boolean change)
          Method to control whether print preview dialog can temporarily change the Look And Feel when creating its user interface components (default: true).
 void clearFooters()
          Clears all the "global" (overall, default) footers for both page 1 and pages 2...n to the empty String "".
 void clearFooters(int which)
          Clears all the "global" (overall, default) footers for either page 1 of pages 2...n to the empty String "".
 void clearHeaders()
          Clears all the "global" (overall, default) headers for both page 1 and pages 2...n to the empty String "" (NOTE: value cannot be changed in Free Trial Version).
 void clearHeaders(int which)
          Clears all the "global" (overall, default) headers for either page 1 of pages 2...n to the empty String "" (NOTE: value cannot be changed in Free Trial Version).
 void clearPageable()
          Remove all pages from this J2Printer's current Pageables list.
static java.lang.Object clone(java.lang.Object obj)
          Convenience method for cloning any Object in Java.
 void displayPDFFile(java.lang.String file)
          Utility method for displaying the contents of a PDF file using Adobe Acrobat Reader (Windows only).
 void dispose()
          Method used to dispose of all internal static J2Printer objects and set them to null, thereby freeing them up for garbage collection.
 void disposePageImageBuffers()
          Method used in conjunction with getPageImage methods to dispose of the page image BufferedImages, freeing them up for garbage collection.
protected  void fire(java.lang.String propertyName)
          Fire property change event for this component
 double getBodyHeight(int which)
          Convenience method which returns the width of the body height (printable area inside the top and bottom margins, headers, footers, and gaps) based on the J2Printer "default" page settings.
 double getBodyWidth()
          Convenience method which returns the width of the body width (printable area inside the left and right margins) based on the J2Printer "default" page settings.
 double getBottomMargin()
          Returns the "global" (overall, default) bottom margin.
 java.lang.Object getCenterFooter()
          Returns the "global" (overall, default) center footer (same as getCenterFooter(FIRST)).
 java.lang.Object getCenterFooter(int which)
          Returns the "global" (overall, default) center footer for either page 1 or pages 2...n.
 java.lang.Object getCenterHeader()
          Returns the "global" (overall, default) center header (same as getCenterHeader(FIRST)).
 java.lang.Object getCenterHeader(int which)
          Returns the "global" (overall, default) center header for either page 1 or pages 2...n.
 int getCurrentPrintPreviewPageNumber()
          Returns the current user-controlled print preview page number.
 double getCurrentPrintPreviewScale()
          Returns the current user-specified print preview scaling factor.
 java.lang.Exception getException()
          Returns the Exception (usually a java.awt.print.PrinterException) that occurred during printing.
 java.awt.Font getFooterFont()
          Returns the "global" (overall, default) Font specified for footers (same as getFooterFont(FIRST) under assumption that footer fonts on all pages are the same).
 java.awt.Font getFooterFont(int which)
          Returns the "global" (overall, default) Font for printing the footers for either page 1 or pages 2...n when these are specified using a String.
 int getFooterStyle()
          Returns "global" (overall, default) footer style (returns answer for page 1).
 int getFooterStyle(int which)
          Returns "global" (overall, default) footer style for either page 1 or pages 2...n.
 double getGapAboveFooter()
          Returns the "global" (overall, default) gap between the last line and the footer in inches.
 double getGapBelowHeader()
          Returns the "global" (overall, default) gap between the header and first line in inches.
 java.awt.Font getHeaderFont()
          Returns the "global" (overall, default) Font specified for headers (same as getHeaderFont(FIRST) under assumption that header fonts on all pages are the same).
 java.awt.Font getHeaderFont(int which)
          Returns the "global" (overall, default) Font for printing the headers for either page 1 or pages 2...n when these are specified using a String.
 int getHeaderStyle()
          Returns the "global" (overall, default) header style (returns answer for page 1).
 int getHeaderStyle(int which)
          Returns the "global" (overall, default) header style for either page 1 or pages 2...n.
 java.lang.Object getLeftFooter()
          Returns the "global" (overall, default) left footer (same as getLeftFooter(FIRST)).
 java.lang.Object getLeftFooter(int which)
          Returns the "global" (overall, default) left footer for either page 1 or pages 2...n.
 java.lang.Object getLeftHeader()
          Returns the "global" (overall, default) left header (same as getLeftHeader(FIRST)).
 java.lang.Object getLeftHeader(int which)
          Returns the "global" (overall, default) left header for either page 1 or pages 2...n.
 double getLeftMargin()
          Returns the "global" (overall, default) left margin.
 java.awt.Dimension getMaximumSize()
          Return maximum size of bean icon (32x32) for use in your visual builder.
 java.awt.Dimension getMinimumSize()
          Return minimum size of bean icon (32x32) for use in your visual builder.
 int getNumberOfCopies()
          Returns the number of copies of the document to be printed as set by setNumberOfCopies (or the Copies attribute set using setPrintRequestAttributeSet under J2Printer14).
 int getNup()
          Returns the N-up value (number of page images printed per physical page).
 int getOrientation()
          Returns the "global" (overall, default) page orientation (PORTRAIT, LANDSCAPE, or REVERSE_LANDSCAPE).
 java.awt.print.Pageable getPageable()
          Returns the Pageable that will be printed.
 int getPageBeingPrinted()
          Returns the current page being printed (1...n).
 java.awt.print.PageFormat getPageFormat()
          Convenience method for creating a PageFormat instance based on this J2Printer's "global" margins, page size, & orientation.
 java.awt.image.BufferedImage getPageImage(int pageNumber)
          Method for creating a BufferedImage representation of the specified page (1...n) of the current Pageable at screen resolution assuming a scale factor of 1.0 and a black box drawn around the outside edge of the page.
 java.awt.image.BufferedImage getPageImage(int pageNumber, double scale, boolean outline, boolean reusable)
          Deprecated. Use instead getPageImage(pageNumber, scale, border, reusable) where border = 0 if outline false and border = 1 if outline true.
 java.awt.image.BufferedImage getPageImage(int pageNumber, double scale, int border, boolean reusable)
          Method for creating a BufferedImage representation of the specified page (1...n) of the current Pageable at screen resolution with a given scale factor and optional black box drawn around the outside edge of the page.
 java.awt.image.BufferedImage getPageImage(java.awt.print.Pageable pageable, int pageNumber, double scale, boolean outline, boolean reusable)
          Deprecated. Use instead getPageImage(pageable, pageNumber, scale, border, reusable) where border = 0 if outline false and border = 1 if outline true.
 java.awt.image.BufferedImage getPageImage(java.awt.print.Pageable pageable, int pageNumber, double scale, int border, boolean reusable)
          Method for creating a BufferedImage representation of the specified page (1...n) of a specified Pageable at screen resolution with a given scale factor and optional black box drawn around the outside edge of the page.
 double getPaperHeight()
          Returns the "global" (overall, default) paper height in 1/72nds of an inch with paper viewed in PORTRAIT.
 double getPaperWidth()
          Returns the "global" (overall, default) paper width in 1/72nds of an inch with paper viewed in PORTRAIT.
 java.awt.Component getParentFrame()
          Returns the parent Frame (or JFrame, JDialog, JWindow, JApplet, or JInternalFrame) over which model print dialogs and wait cursors are displayed.
 java.awt.Dimension getPreferredSize()
          Return preferred size of bean icon (32x32) for use in your visual builder.
 java.awt.print.PrinterJob getPrinterJob()
          Returns the currently specified PrinterJob used by J2Printer.
 java.lang.String getPrintJobName()
          Returns the print job name for this document as set by setPrintJobName (or the JobName attribute set using setPrintRequestAttributeSet under J2Printer14)
 int getPrintPreviewCloseOnPrint()
          Returns value of the print preview dialog close-on-print setting (J2Printer.BEFORE, .WAIT, or .NEVER).
 int getPrintPreviewPageNumber()
          Returns the starting print preview page number.
 java.awt.Dialog getPrintPreviewPageSetupDialog()
          Returns the current print preview dialog's page setup Dialog.
 double getPrintPreviewScale()
          Returns the starting print preview scaling factor.
 java.lang.String getPrintPreviewString(java.lang.String name)
          Deprecated. Use customizable print preview toolbar mechanism to find out print preview toolbar strings and/or tooltips (see J2Printer documentation). NOTE: calling this method restores the print preview toolbar to its default appearance.
 javax.swing.JToolBar getPrintPreviewToolBar()
          Method for gaining access to the print preview dialog toolbar for purposes of customization (see J2PrinterWorks documentation for J2Printer).
 java.lang.Object getRightFooter()
          Returns the "global" (overall, default) right footer (same as getRightFooter(FIRST)).
 java.lang.Object getRightFooter(int which)
          Returns the "global" (overall, default) right footer for either page 1 or pages 2...n.
 java.lang.Object getRightHeader()
          Returns the "global" (overall, default) right header (same as getRightHeader(FIRST)).
 java.lang.Object getRightHeader(int which)
          Returns the "global" (overall, default) right header for either page 1 or pages 2...n.
 double getRightMargin()
          Returns the "global" (overall, default) right margin.
 double getScale()
          Returns the "global" (overall, default) magnification or minification scaling factor for printing.
 int getStartingPageNumber()
          Returns the starting page number, that is, the number used to number the first page of the document.
 double getTopMargin()
          Returns the "global" (overall, default) top margin.
static java.lang.String getVersion()
          Returns the J2PrinterWorks version number.
 boolean isCrossPlatformDialogs()
          Returns whether J2Printer is using cross platform dialogs (overridden in J2Printer14 subclass, J2Printer always returns false)
 boolean isCurrentPrintPreviewTwoPageDisplay()
          Returns whether print preview dialog is currently in one or two page display mode as specified by the user.
 boolean isDebug()
          Returns whether stack trace and other debug information will print to System.err when errors are encountered (default: true).
 boolean isPrintDialogResponse()
          Returns the most recent user response to the print dialog box, true = "OK" or false = "cancel".
 boolean isPrintDialogUsed()
          Returns whether to display a print dialog before printing.
 boolean isPrintingUnderway()
          Returns whether printing is underway.
 boolean isPrintPreviewClosed()
          Returns whether the print preview dialog is open or closed.
 boolean isPrintPreviewTwoPageDisplay()
          Returns whether print preview dialog starts in one or two page display mode.
 boolean isSeparatePrintThread()
          Returns whether printing will be performed from a separate thread.
 java.awt.print.Pageable joinPageables(java.awt.print.Pageable pageable1, java.awt.print.Pageable pageable2)
          Create new Pageable out of two existing Pageables.
static void main(java.lang.String[] args)
          Double click on J2PrinterWorks.jar to find out its version number and date.
 javax.swing.JPanel makePagePanel(int which)
          Convenience factory method to create a JPanel whose size is the same size as the body of a printable page based on the J2Printer "default" settings.
 java.awt.print.Pageable mergePageables(java.util.Vector pageables)
          Create new Pageable out of a vector of existing Pageables
 void paint(java.awt.Graphics g)
          This method is provided to paint the J2Printer bean icon in your visual builder.
 void print()
          Method for printing the current Pageable (specified using setPageable)
 void print(java.awt.print.Pageable pageable)
          Method for printing any Pageable (or Book)
 void printPDFFile(java.lang.String file)
          Utility method for printing the contents of a PDF file on the current printer (Windows only).
 void printToHTML(java.lang.String dir, java.lang.String file, double scale, boolean slideshow)
          Utility method for saving a facsimile of the printed document either as a single HTML file containing all the page images or as a series of HTML pages suitable for display in a browser as a slide show.
 byte[] printToPDF()
          Utility method for printing the current document to PDF stored in an in-memory byte array.
 void printToPDF(java.io.OutputStream outputStream)
          Utility method for printing the current document to PDF and storing in a provided OutputStream.
 void printToPDF(java.lang.String file)
          Utility method for printing the current document to a PDF (.pdf) file.
 byte[] printToPDFNoFonts()
          Utility method for printing the current document to PDF stored in an in-memory byte array that relies on no PDF fonts.
 void printToPDFNoFonts(java.io.OutputStream outputStream)
          Utility method for printing the current document to PDF and storing in a provided OutputStream that relies on no PDF fonts.
 void printToPDFNoFonts(java.lang.String file)
          Utility method for printing the current document to a PDF (.pdf) file that relies on no PDF fonts.
 void refreshPrintPreviewDialog()
          Method for refreshing the print preview dialog window using the current settings.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a PropertyChangeListener for this component
 void saveImageToJPEG(java.awt.image.BufferedImage image, java.lang.String fileName)
          Utility method for saving a BufferedImage to a JPEG file.
 void setBottomMargin(double bottomMargin)
          Sets the "global" (overall, default) bottom margin below footer in inches from the edge of the page (when viewing content).
static void setBusyCursor(java.awt.Component parent, boolean busy)
          Convenience method that sets the cursor on your Frame (or JFrame, JDialog, JWindow, JApplet, or JInternalFrame) to Cursor.WAIT_CURSOR if busy is true, and to Cursor.DEFAULT_CURSOR if busy is false.
 void setCenterFooter(int which, java.lang.Object centerFooter)
          Sets the "global" (overall, default) center footer for either page 1 or pages 2...n using a String or JLabel
 void setCenterFooter(java.lang.Object centerFooter)
          Sets the "global" (overall, default) center footer for both page 1 and pages 2...n using a String or JLabel.
 void setCenterHeader(int which, java.lang.Object centerHeader)
          Sets the "global" (overall, default) center header for either page 1 or pages 2...n using a String or JLabel (NOTE: value cannot be changed in Free Trial Version).
 void setCenterHeader(java.lang.Object centerHeader)
          Sets the "global" (overall, default) center header for both page 1 and pages 2...n using a String or JLabel (NOTE: value cannot be changed in Free Trial Version).
 void setDebug(boolean debug)
          Specifies whether stack trace and other debug information will print to System.err when errors are encountered.
 void setFooterFont(java.awt.Font font)
          Sets the "global" (overall, default) Font for printing the footers for both page 1 and pages 2...n when these are specified using a String.
 void setFooterFont(int which, java.awt.Font font)
          Sets the "global" (overall, default) Font for printing the footers for either page 1 or pages 2...n when these are specified using a String.
 void setFooterStyle(int style)
          Sets "global" (overall, default) footer style for both page 1 and pages 2...n.
 void setFooterStyle(int which, int style)
          Sets "global" (overall, default) footer style for either page 1 or pages 2...n.
 void setGapAboveFooter(double gapAboveFooter)
          Sets the "global" (overall, default) gap between the bottom of the last line of body and the top of the footer in inches.
 void setGapBelowHeader(double gapBelowHeader)
          Sets the "global" (overall, default) gap between the bottom of the header and the top of the first line of body in inches.
 void setHeaderFont(java.awt.Font font)
          Sets the "global" (overall, default) Font for printing the headers for both page 1 and pages 2...n when these are specified using a String (NOTE: value cannot be changed in Free Trial Version).
 void setHeaderFont(int which, java.awt.Font font)
          Sets the "global" (overall, default) Font for printing the headers for either page 1 or pages 2...n when these are specified using a String (NOTE: value cannot be changed in Free Trial Version).
 void setHeaderStyle(int style)
          Sets the "global" (overall, default) header style for both page 1 and pages 2...n (NOTE: value cannot be changed in Free Trial Version).
 void setHeaderStyle(int which, int style)
          Sets the "global" (overall, default) header style for either page 1 or pages 2...n (NOTE: value cannot be changed in Free Trial Version).
 void setLeftFooter(int which, java.lang.Object leftFooter)
          Sets the "global" (overall, default) left footer for either page 1 or pages 2...n using a String or JLabel
 void setLeftFooter(java.lang.Object leftFooter)
          Sets the "global" (overall, default) left footer for both page 1 and pages 2...n using a String or JLabel.
 void setLeftHeader(int which, java.lang.Object leftHeader)
          Sets the "global" (overall, default) left header for either page 1 or pages 2...n using a String or JLabel (NOTE: value cannot be changed in Free Trial Version).
 void setLeftHeader(java.lang.Object leftHeader)
          Sets the "global" (overall, default) left header for both page 1 and pages 2...n using a String or JLabel.
 void setLeftMargin(double leftMargin)
          Sets the "global" (overall, default) left margin in inches from the edge of the page (when viewing content).
 void setNumberOfCopies(int numberOfCopies)
          Sets number of copies to be printed (and appear in the print dialog).
 void setNumberOfPageImageBuffers(int numberBuffers)
          Method used in conjunction with getPageImage methods, and thereby the print preview dialog, specifying how many BufferedImages can be allocated simultaneously before their space gets reused.
 void setNup(int nup)
          Sets printing to use N-up formating (N page images per physical page), where N=1, 2, 4, 6, 9, or 16, or minus these same values, where the minus sign means suppress the drawing of the page outlines.
 void setOrientation(int orientation)
          Sets "global" (overall, default) page orientation (causes corresponding reordering of unprintable margin settings)
 void setPageable(java.awt.print.Pageable pageable)
          Specifies the Pageable that will be printed.
 void setPageFormat(java.awt.print.PageFormat pageFormat)
          Convenience method for setting this J2Printer's "global" margins, page size, and orientation from an external PageFormat instance.
 void setPageImagesMonochrome(boolean monochrome)
          Method used in conjunction with the getPageImage methods, and thereby the print preview dialog page images, specifying whether the images are monochrome (grayscale) instead of color (default: false = color).
 void setPaperSize(double paperW, double paperH)
          Sets the "global" (overall, default) paper width and height in 1/72nds of an inch when paper viewed in PORTRAIT.
 void setParam(java.lang.String str)
          Method for entering internal parameters, such as the J2PrinterWorks serial number.
 void setParentFrame(java.awt.Component parent)
          Set the parent Frame (or JFrame, JDialog, JWindow, JApplet, or JInternalFrame) from which the print dialog, print preview, and page setup modal dialogs are displayed.
 void setPrintDialogUsed(boolean printDialogUsed)
          Sets whether to show a print dialog before printing.
 void setPrinterJob(java.awt.print.PrinterJob printerJob)
          Use the specified PrinterJob for J2Printer printing.
 void setPrintJobName(java.lang.String printJobName)
          Sets the print job name that appears in the system print monitor.
 void setPrintPreviewCloseOnPrint(int closeOnPrint)
          Specifies whether and when the print preview dialog will close when user hits "Print" button.
 void setPrintPreviewDialogZoomLevels(int[] zoomLevels)
          Method used to change the print preview dialog zoom levels.
 void setPrintPreviewIconImage(java.awt.Image icon)
          Method to set the icon image in the upper left hand corner of the print preview dialog (default: same as parent frame).
 void setPrintPreviewPageNumber(int pageNumber)
          Sets the starting page number displayed in the print preview dialog.
 void setPrintPreviewPageSetupDialog(java.awt.Dialog dialog)
          Sets the page setup dialog to display when user hits "Page Setup" button in print preview dialog.
 void setPrintPreviewScale(double printPreviewScale)
          Sets the starting magnification/minification scale of the print preview dialog.
 void setPrintPreviewString(java.lang.String name, java.lang.String value)
          Deprecated. Use customizable print preview toolbar mechanism to change print preview toolbar strings and/or tooltips (see J2Printer documentation). NOTE: calling this method restores the print preview toolbar to its default appearance.
 void setPrintPreviewTwoPageDisplay(boolean twoPageDisplay)
          Specifies whether print preview dialog starts in one or two page display mode.
 void setRightFooter(int which, java.lang.Object rightFooter)
          Sets the "global" (overall, default) right footer for either page 1 or pages 2...n using a String or JLabel.
 void setRightFooter(java.lang.Object rightFooter)
          Sets the "global" (overall, default) right footer for both page 1 and pages 2...n using a String or JLabel.
 void setRightHeader(int which, java.lang.Object rightHeader)
          Sets the "global" (overall, default) right header for either page 1 or pages 2...n using a String or JLabel (NOTE: value cannot be changed in Free Trial Version).
 void setRightHeader(java.lang.Object rightHeader)
          Sets the "global" (overall, default) right header for both page 1 and pages 2...n using a String or JLabel (NOTE: value cannot be changed in Free Trial Version).
 void setRightMargin(double rightMargin)
          Sets the "global" (overall, default) right margin in inches from the edge of the page (when viewing content).
 void setScale(double scale)
          Sets "global" (overall, default) magnification or minification scaling factor for printing.
 void setSeparatePrintThread(boolean separatePrintThread)
          Sets whether to print from a separate thread (instead of from the same thread that called the print method).
 void setStartingPageNumber(int startingPageNumber)
          Sets the starting page number, that is, the number used to number the first page of the document.
 void setTopMargin(double topMargin)
          Sets the "global" (overall, default) top margin above header in inches from the edge of the page when viewing content).
 java.awt.print.PageFormat showPageSetupDialog()
          Method for showing the standard Page Setup dialog with the current J2Printer (overall, default) orientation and margin settings.
 java.awt.print.PageFormat showPageSetupDialog(J2Pageable pageable)
          Method for showing the standard Page Setup dialog with the specified J2Pageable's orientation and margin settings.
 void showPrintPreviewDialog()
          Method for showing a modal Print Preview dialog for this J2Printer instance's current Pageable.
 void showPrintPreviewDialog(java.awt.Component parent)
          Method for showing a modal Print Preview dialog for this J2Printer instance's current Pageable.
 void showPrintPreviewDialog(java.awt.Container parent, java.awt.print.Pageable pageable)
          Method for showing a modal Print Preview dialog for any Pageable (including non-J2PrinterWorks Pageables).
 void showPrintPreviewDialog(java.awt.print.Pageable pageable)
          Method for showing a modal Print Preview dialog for any Pageable (including non-J2PrinterWorks Pageables).
 void showPrintPreviewPageSetupButton(boolean showPageSetupButton)
          Deprecated. Use customizable print preview toolbar mechanism to add or remove buttons (see J2Printer documentation).
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FIRST

public static final int FIRST
Denotes values for page 1.

See Also:
Constant Field Values

REST

public static final int REST
Denotes values for pages 2...n.

See Also:
Constant Field Values

NONE

public static final int NONE
Specifies that no additional line or box is drawn for the header or footer.

See Also:
Constant Field Values

LINE

public static final int LINE
Specifies that a line is drawn below the header or above the footer.

See Also:
Constant Field Values

BOX

public static final int BOX
Specifies that a box is drawn around the header or the footer.

See Also:
Constant Field Values

PLAIN

public static final int PLAIN
Specifies that no outline is drawn around the page image returned by getPageImage.

See Also:
Constant Field Values

OUTLINE

public static final int OUTLINE
Specifies that an outline is drawn around the page image returned by getPageImage.

See Also:
Constant Field Values

SHADOW

public static final int SHADOW
Specifies that an outline and a drop shadow are drawn around the page image returned by getPageImage.

See Also:
Constant Field Values

LANDSCAPE

public static final int LANDSCAPE
Specifies that the page orientation is landscape (content rotated 90 degrees counter-clockwise relative to portrait).

See Also:
Constant Field Values

PORTRAIT

public static final int PORTRAIT
Specifies that the page orientation is portrait.

See Also:
Constant Field Values

REVERSE_LANDSCAPE

public static final int REVERSE_LANDSCAPE
Specifies that the page orientation is reverse landscape (landscape rotated 180 degrees).

See Also:
Constant Field Values

CENTER

public static final int CENTER
Specifies horizontal or vertical alignment to be centered within the available space.

See Also:
Constant Field Values

LEFT

public static final int LEFT
Specifies horizontal alignment to be left justified within the available space.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Specifies horizontal alignment to be right justified within the available space.

See Also:
Constant Field Values

TOP

public static final int TOP
Specifies vertical alignment to be top justified within the available space.

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
Specifies vertical alignment to be bottom justified within the available space.

See Also:
Constant Field Values

BEFORE

public static final int BEFORE
Specifies that print preview dialog should be closed bringing up print dialog.

See Also:
Constant Field Values

WAIT

public static final int WAIT
Specifies that print preview dialog should be closed after print dialog comes up (or after printing begins if not using print dialog).

See Also:
Constant Field Values

NEVER

public static final int NEVER
Specifies that print preview dialog should be kept open until closed manually by user.

See Also:
Constant Field Values

PPI72

public static final int PPI72
A constant specifying the standard printing resolution of 72 dots ("points") per inch.

See Also:
Constant Field Values

GLOBAL

public static final int GLOBAL
Indicates that the "global" (overall, default, J2Printer) values are to be used for margins, header/footer style, orientation, etc., as opposed to the "local" (individual Pageable) values.

See Also:
Constant Field Values

printerJob

protected static java.awt.print.PrinterJob printerJob

printerJobSeparateThread

protected static java.awt.print.PrinterJob printerJobSeparateThread
Constructor Detail

J2Printer

public J2Printer()
Construct a J2Printer object with no serial number, a default printer, and an empty Pageable.


J2Printer

public J2Printer(java.awt.print.PrinterJob printerJob)
Construct a J2Printer object with no serial number, a given PrinterJob, and an empty Pageable.


J2Printer

public J2Printer(java.lang.String serialNum)
Construct a J2Printer object with given serial number, default printer, and empty Pageable.


J2Printer

public J2Printer(java.lang.String serialNum,
                 java.awt.print.PrinterJob printerJob)
Construct a J2Printer object with given serial number and PrinterJob, and empty Pageable.

Method Detail

setParam

public void setParam(java.lang.String str)
Method for entering internal parameters, such as the J2PrinterWorks serial number.


setPrinterJob

public void setPrinterJob(java.awt.print.PrinterJob printerJob)
Use the specified PrinterJob for J2Printer printing. You can use this to set up your own PrinterJob instance rather than let J2Printer determine this for you.

Parameters:
printerJob - PrinterJob to use for printing. PrinterJob instance will also be used to set the number of copies and print job name. If null, the default printer will be used, with 1 copy, and job name "J2PrinterWorks print document".

getPrinterJob

public java.awt.print.PrinterJob getPrinterJob()
Returns the currently specified PrinterJob used by J2Printer.


mergePageables

public java.awt.print.Pageable mergePageables(java.util.Vector pageables)
Create new Pageable out of a vector of existing Pageables

Parameters:
pageables - A Vector of Pageables
Returns:
Pageable

joinPageables

public java.awt.print.Pageable joinPageables(java.awt.print.Pageable pageable1,
                                             java.awt.print.Pageable pageable2)
Create new Pageable out of two existing Pageables.

Parameters:
pageable1 -
pageable2 -
Returns:
Pageable

showPageSetupDialog

public java.awt.print.PageFormat showPageSetupDialog()
Method for showing the standard Page Setup dialog with the current J2Printer (overall, default) orientation and margin settings. If user hits "OK", the J2Printer's orientation and margin settings will be updated to values specified in dialog. If user hits "cancel", values are left unchanged. Bug in JDK 1.2.2: margins in dialog always initialized to 1" regardless of current margin settings.


showPageSetupDialog

public java.awt.print.PageFormat showPageSetupDialog(J2Pageable pageable)
Method for showing the standard Page Setup dialog with the specified J2Pageable's orientation and margin settings. Works for any J2Pageable subclass including J2TextPrinter, J2TablePrinter, J2TreePrinter, J2ComponentPrinter, and J2FlowPrinter. If user hits "OK", the J2Pageable's orientation and margin settings will be updated to values specified in dialog. If user hits "cancel", values are left unchanged. Bug in JDK 1.2.2: margins in dialog always initialized to 1" regardless of current margin settings.

Parameters:
pageable - Pageable whose orientation and margin settings will be displayed

print

public void print(java.awt.print.Pageable pageable)
Method for printing any Pageable (or Book)

Parameters:
pageable - Pageable (or Book) that will be printed

print

public void print()
Method for printing the current Pageable (specified using setPageable)


cancelPrinting

public void cancelPrinting()
Cancel the current printing job. This cancels the Java imaging for the current PrinterJob, but does not cancel the actual printing once the output has been spooled to the OS.


showPrintPreviewDialog

public void showPrintPreviewDialog(java.awt.Container parent,
                                   java.awt.print.Pageable pageable)
Method for showing a modal Print Preview dialog for any Pageable (including non-J2PrinterWorks Pageables). Can control starting page, starting scale, one vs. two page display, page setup dialog (see associated methods below). This call makes the specified Pageable this J2Printer's setPageable.

Parameters:
parent - The parent Frame (or JFrame, JDialog, JWindow, JApplet, or JInternalFrame) from which the dialog is displayed. Causes these windows to be treated as a group when clicked on to minimize or "bring to front". If no parent frame or you don't care about window management, use null for this argument.
pageable - Pageable the Pageable (or Book) for which to show the print preview.
See Also:
setPrintPreviewScale(double), setPrintPreviewPageNumber(int), setPrintPreviewTwoPageDisplay(boolean), setPrintPreviewPageSetupDialog(Dialog), showPrintPreviewPageSetupButton(boolean)

showPrintPreviewDialog

public void showPrintPreviewDialog(java.awt.Component parent)
Method for showing a modal Print Preview dialog for this J2Printer instance's current Pageable. Can control starting page, starting scale, one vs. two page display, page setup dialog (see associated methods below).

Parameters:
parent - The parent Frame (or JFrame, JDialog, JWindow, JApplet, or JInternalFrame) from which the dialog is displayed. Causes these windows to be treated as a group when clicked on to minimize or "bring to front". If no parent frame or you don't care about window management, use null for this argument.
See Also:
setPrintPreviewScale(double), setPrintPreviewPageNumber(int), setPrintPreviewTwoPageDisplay(boolean), setPrintPreviewPageSetupDialog(Dialog), showPrintPreviewPageSetupButton(boolean)

showPrintPreviewDialog

public void showPrintPreviewDialog()
Method for showing a modal Print Preview dialog for this J2Printer instance's current Pageable. Can control starting page, starting scale, one vs. two page display, page setup dialog (see associated methods below). Assumes parent frame set by setParentFrame (default: null)

See Also:
setPrintPreviewScale(double), setPrintPreviewPageNumber(int), setPrintPreviewTwoPageDisplay(boolean), setPrintPreviewPageSetupDialog(Dialog), showPrintPreviewPageSetupButton(boolean), setParentFrame(Component)

showPrintPreviewDialog

public void showPrintPreviewDialog(java.awt.print.Pageable pageable)
Method for showing a modal Print Preview dialog for any Pageable (including non-J2PrinterWorks Pageables). Can control starting page, starting scale, one vs. two page display, page setup dialog (see associated methods below). This call makes the specified Pageable this J2Printer's setPageable. Assumes parent frame set by setParentFrame (default: null)

Parameters:
pageable - Pageable the Pageable (or Book) for which to show the print preview.
See Also:
setPrintPreviewScale(double), setPrintPreviewPageNumber(int), setPrintPreviewTwoPageDisplay(boolean), setPrintPreviewPageSetupDialog(Dialog), showPrintPreviewPageSetupButton(boolean), setParentFrame(Component)

changePrintPreviewLookAndFeel

public void changePrintPreviewLookAndFeel(boolean change)
Method to control whether print preview dialog can temporarily change the Look And Feel when creating its user interface components (default: true). When it creates its user interface compoments, the print preview dialog sets the Look And Feel to either the CrossPlatformLookAndFeel or the SystemLookAndFeel depending on whether crossPlatformDialogs is true or false. This occurs only the first time the print preview dialog is shown or getPrintPreviewToolBar is called. When it does so, the application Look and Feel is saved and restored. However, some application Look and Feels and/or third-party components that have their own Look and Feel do not work properly if the application Look and Feel ever changed. If so, the method changePrintPreviewLookAndFeel(false) can be called to prevent the print preview dialog from changing the Look And Feel and instead use the current Look and Feel when it creates its user interface componets. In this case you may need to adjust the sizes, borders, spacing, fonts, colors, etc. of the print preview dialog user interface components so they look good under the prevailing Look and Feel (use getPrintPreviewToolBar to obtain references to these).

Parameters:
change - boolean specifying whether the print preview dialog can temporarily change the Look and Feel when creating user interface components

getPrintPreviewToolBar

public javax.swing.JToolBar getPrintPreviewToolBar()
Method for gaining access to the print preview dialog toolbar for purposes of customization (see J2PrinterWorks documentation for J2Printer).


refreshPrintPreviewDialog

public void refreshPrintPreviewDialog()
Method for refreshing the print preview dialog window using the current settings.


showPrintPreviewPageSetupButton

public void showPrintPreviewPageSetupButton(boolean showPageSetupButton)
Deprecated. Use customizable print preview toolbar mechanism to add or remove buttons (see J2Printer documentation).

Method to specify whether to include Page Setup button in Print Preview dialog (default: true)


setPrintPreviewIconImage

public void setPrintPreviewIconImage(java.awt.Image icon)
Method to set the icon image in the upper left hand corner of the print preview dialog (default: same as parent frame). Note: feature only supported as of JDK 1.6, has no effect under earlier JDK releases.

Parameters:
icon - Image specifying the Image to use for the print preview dialog icon image
Since:
1.6

setPrintPreviewString

public void setPrintPreviewString(java.lang.String name,
                                  java.lang.String value)
Deprecated. Use customizable print preview toolbar mechanism to change print preview toolbar strings and/or tooltips (see J2Printer documentation). NOTE: calling this method restores the print preview toolbar to its default appearance.

Method for specifying Print Preview dialog strings used for localization.
For example, use:
      setString("PRINTPREVIEW", "This string specifies the Print Preview dialog title bar");

Parameters:
name - String specifying which string to change, legal arguments are: PRINT, PREVIOUSPAGE, NEXTPAGE, PAGESETUP, DONE, FIRSTPAGE, LASTPAGE, ZOOMOUT, ZOOMIN, TWOPAGEDISPLAY, ONEPAGEDISPLAY, PAGE, OF, PRINTPREVIEW.
value - String specifying new value for this string.

getPrintPreviewString

public java.lang.String getPrintPreviewString(java.lang.String name)
Deprecated. Use customizable print preview toolbar mechanism to find out print preview toolbar strings and/or tooltips (see J2Printer documentation). NOTE: calling this method restores the print preview toolbar to its default appearance.

Method for getting the current Print Preview dialog strings used for localization.
For example, use:
      getString("PRINTPREVIEW");

Parameters:
name - String specifying which string to change, legal arguments are: PRINT, PREVIOUSPAGE, NEXTPAGE, PAGESETUP, DONE, FIRSTPAGE, LASTPAGE, ZOOMOUT, ZOOMIN, TWOPAGEDISPLAY, ONEPAGEDISPLAY, PAGE, OF, PRINTPREVIEW.

setBusyCursor

public static void setBusyCursor(java.awt.Component parent,
                                 boolean busy)
Convenience method that sets the cursor on your Frame (or JFrame, JDialog, JWindow, JApplet, or JInternalFrame) to Cursor.WAIT_CURSOR if busy is true, and to Cursor.DEFAULT_CURSOR if busy is false.

Parameters:
parent - the Frame (or JFrame, JDialog, JWindow, JApplet, or JInternalFrame), over which the cursor will be changed (no change to cursor if null).
busy - boolean specifying WAIT_CURSOR if true, DEFAULT_CURSOR if false.

setParentFrame

public void setParentFrame(java.awt.Component parent)
Set the parent Frame (or JFrame, JDialog, JWindow, JApplet, or JInternalFrame) from which the print dialog, print preview, and page setup modal dialogs are displayed. Optional, but if specified then J2PrinterWorks will display a wait cursor over the parent during long operations and model dialog window activation will be tied to the parent frame.

Parameters:
parent - the Frame (or JFrame, JDialog, JWindow, JApplet, or JInternalFrame) from which the print dialog, print preview, and page setup will be displayed.

getParentFrame

public java.awt.Component getParentFrame()
Returns the parent Frame (or JFrame, JDialog, JWindow, JApplet, or JInternalFrame) over which model print dialogs and wait cursors are displayed.


getPageImage

public java.awt.image.BufferedImage getPageImage(int pageNumber)
Method for creating a BufferedImage representation of the specified page (1...n) of the current Pageable at screen resolution assuming a scale factor of 1.0 and a black box drawn around the outside edge of the page. Each return value is a new, independent BufferedImage allocated on the heap, so you need to set any saved reference g * to null when you are done using it so it gets garbage collected! Other variants of getPageImage allow you to control whether the same BufferedImage can be reused when a later call is made.

Parameters:
pageNumber - the number of the page (1...n) to be returned as an Image.
Returns:
BufferedImage (a concrete subclass of Image)
See Also:
saveImageToJPEG(java.awt.image.BufferedImage, java.lang.String)

getPageImage

public java.awt.image.BufferedImage getPageImage(int pageNumber,
                                                 double scale,
                                                 boolean outline,
                                                 boolean reusable)
Deprecated. Use instead getPageImage(pageNumber, scale, border, reusable) where border = 0 if outline false and border = 1 if outline true.

Method for creating a BufferedImage representation of the specified page (1...n) of the current Pageable at screen resolution with a given scale factor and optional black box drawn around the outside edge of the page.

Parameters:
pageNumber - the number of the page (1...n) to be returned as an Image.
scale - double specifying the minification/magnification factor for the Image.
outline - boolean specifying whether to draw a black box around the outside edge of the page.
reusable - boolean where "true" means it is OK to reuse this BufferedImage when a later call on getPageImage is made and "false" means create a new, independent BufferedImage allocated on the heap that will not be reused. Specifying reusable = "true" means that this returned BufferedImage becomes invalid after a certain number of setPageImage calls, where this number is specified by the method setNumberOfPageImageBuffers and has a default value of 1.
Returns:
BufferedImage (a concrete subclass of Image)
See Also:
saveImageToJPEG(java.awt.image.BufferedImage, java.lang.String)

getPageImage

public java.awt.image.BufferedImage getPageImage(java.awt.print.Pageable pageable,
                                                 int pageNumber,
                                                 double scale,
                                                 boolean outline,
                                                 boolean reusable)
Deprecated. Use instead getPageImage(pageable, pageNumber, scale, border, reusable) where border = 0 if outline false and border = 1 if outline true.

Method for creating a BufferedImage representation of the specified page (1...n) of a specified Pageable at screen resolution with a given scale factor and optional black box drawn around the outside edge of the page.

Parameters:
pageable - the Pageable to be imaged.
pageNumber - the number of the page (1...n) to be returned as an Image.
scale - double specifying the minification/magnification factor for the Image.
outline - boolean specifying whether to draw a black box around the outside edge of the page.
reusable - boolean where "true" means it is OK to reuse this BufferedImage when a later call getPageImage is made and "false" means create a new, independent BufferedImage allocated on the heap that will not be reused. Specifying reusable = "true" means that this returned BufferedImage becomes invalid after a certain number of setPageImage calls, where this number is specified by the method setNumberOfPageImageBuffers and has a default value of 1.
Returns:
BufferedImage (a concrete subclass of Image)
See Also:
saveImageToJPEG(java.awt.image.BufferedImage, java.lang.String)

getPageImage

public java.awt.image.BufferedImage getPageImage(int pageNumber,
                                                 double scale,
                                                 int border,
                                                 boolean reusable)
Method for creating a BufferedImage representation of the specified page (1...n) of the current Pageable at screen resolution with a given scale factor and optional black box drawn around the outside edge of the page.

Parameters:
pageNumber - the number of the page (1...n) to be returned as an Image.
scale - double specifying the minification/magnification factor for the Image.
border - int where border = .PLAIN means draw no border, = .OUTLINE means draw a black box around the outside edge of the page, = .SHADOW means draw black box around the outside edge of page as well as a drop shadow.
reusable - boolean where "true" means it is OK to reuse this BufferedImage when a later call on getPageImage is made and "false" means create a new, independent BufferedImage allocated on the heap that will not be reused. Specifying reusable = "true" means that this returned BufferedImage becomes invalid after a certain number of setPageImage calls, where this number is specified by the method setNumberOfPageImageBuffers and has a default value of 1.
Returns:
BufferedImage (a concrete subclass of Image)
See Also:
saveImageToJPEG(java.awt.image.BufferedImage, java.lang.String)

getPageImage

public java.awt.image.BufferedImage getPageImage(java.awt.print.Pageable pageable,
                                                 int pageNumber,
                                                 double scale,
                                                 int border,
                                                 boolean reusable)
Method for creating a BufferedImage representation of the specified page (1...n) of a specified Pageable at screen resolution with a given scale factor and optional black box drawn around the outside edge of the page.

Parameters:
pageable - the Pageable to be imaged.
pageNumber - the number of the page (1...n) to be returned as an Image.
scale - double specifying the minification/magnification factor for the Image.
border - int where border = .NONE (0) means draw no border, = .OUTLINE (1) means draw a black box around the outside edge of the page, = .SHADOW (2) means draw black box around the outside edge of page as well as a drop shadow.
reusable - boolean where "true" means it is OK to reuse this BufferedImage when a later call getPageImage is made and "false" means create a new, independent BufferedImage allocated on the heap that will not be reused. Specifying reusable = "true" means that this returned BufferedImage becomes invalid after a certain number of setPageImage calls, where this number is specified by the method setNumberOfPageImageBuffers and has a default value of 1.
Returns:
BufferedImage (a concrete subclass of Image)
See Also:
saveImageToJPEG(java.awt.image.BufferedImage, java.lang.String)

setNumberOfPageImageBuffers

public void setNumberOfPageImageBuffers(int numberBuffers)
Method used in conjunction with getPageImage methods, and thereby the print preview dialog, specifying how many BufferedImages can be allocated simultaneously before their space gets reused. For example, if the specified value is 2 (as is the case for the two-page print preview), then after getPageImage is called twice with reusable==true, a third call causes the first BufferedImage space to be reused so that the first BufferedImage contents is no longer valid. The default value is 1, meaning that each call on getPageImage invalidates the contents of the previous returned value.

Parameters:
numberBuffers - int specifying the number of BufferedImages that can be allocated simultaneously before being reused.

disposePageImageBuffers

public void disposePageImageBuffers()
Method used in conjunction with getPageImage methods to dispose of the page image BufferedImages, freeing them up for garbage collection.


setPageImagesMonochrome

public void setPageImagesMonochrome(boolean monochrome)
Method used in conjunction with the getPageImage methods, and thereby the print preview dialog page images, specifying whether the images are monochrome (grayscale) instead of color (default: false = color).

Parameters:
monochrome - boolean if true then the getPageImage methods and print preview dialog page images will be drawn in monochrome (8-bit gray scale), whereas if false then images are drawn in color (int RGB).

setPrintPreviewDialogZoomLevels

public void setPrintPreviewDialogZoomLevels(int[] zoomLevels)
Method used to change the print preview dialog zoom levels.

Parameters:
zoomLevels - int[] an array of desired zoom levels expressed in percent and in low-to-high order. Default values are { 25, 35, 50, 75, 100, 125, 150, 200, 300, 400 }.

saveImageToJPEG

public void saveImageToJPEG(java.awt.image.BufferedImage image,
                            java.lang.String fileName)
Utility method for saving a BufferedImage to a JPEG file.

Parameters:
image - An instance of BufferedImage to be saved.
fileName - A String giving the file name in which to save the BufferedImage (all folders in path must already exist).
See Also:
getPageImage(int)

printToHTML

public void printToHTML(java.lang.String dir,
                        java.lang.String file,
                        double scale,
                        boolean slideshow)
Utility method for saving a facsimile of the printed document either as a single HTML file containing all the page images or as a series of HTML pages suitable for display in a browser as a slide show. For the slide show, an HTML frame set is used to display a table of contents on the left and each page image on the right. The table of contents provides random access to any page, and clicking on any page goes to the next page. The individual pages can also be displayed by themselves, each linked to the next page. NOTE: This method honors the current setSeparatePrintThread(boolean) setting, for which the default is true, so that by default printToHTML is asynchronous and returns immediately. To ensure that the HTML files are completely formed, you need to either call setSeparatePrintThread(false) or wait for the PrintingEventHandler printingDone event.

Parameters:
dir - The file system path name to a directory where all the HTML files will be created (if missing, assumes ".", all folders in path must already exist).
file - The HTML file name that is to be the main window of the slide show (if missing, assumes index.html, if doesn't end in .html, will add .html).
scale - The scale factor (1.0 means 100%) for scaling the page images for display.
slideshow - Specifies whether to generate an HTML slide show (true) or a single HTML file (false).

printToPDF

public void printToPDF(java.lang.String file)
Utility method for printing the current document to a PDF (.pdf) file. NOTE 1: This method honors the current setSeparatePrintThread(boolean) setting, for which the default is true, so that by default printToPDF(file) is asynchronous and returns immediately. To ensure that the file is completely formed, you need to either call setSeparatePrintThread(false) or wait for the PrintingEventHandler printingDone event. NOTE 2: Requires iText jar, downloadable from http://www.lowagie.com/iText, available for free under MPL and/or LGPL licenses.

Parameters:
file - The file name into which the PDF file will be written (if missing, assumes ./out.pdf, if doesn't end in .pdf, will add .pdf, all folders in path must already exist).

printToPDF

public byte[] printToPDF()
Utility method for printing the current document to PDF stored in an in-memory byte array. NOTE 1: This method ignores the current setSeparatePrintThread(boolean) setting, and does not return until printing to the byte array is complete. NOTE 2: Requires iText jar, downloadable from http://www.lowagie.com/iText, available for free under MPL and/or LGPL licenses.


printToPDF

public void printToPDF(java.io.OutputStream outputStream)
Utility method for printing the current document to PDF and storing in a provided OutputStream. NOTE 1: This method honors the current setSeparatePrintThread(boolean) setting, for which the default is true, so that by default printToPDF(outputStream) is asynchronous and returns immediately. To ensure that the outputStream is completely formed, you need to either call setSeparatePrintThread(false) or wait for the PrintingEventHandler printingDone event. NOTE 2: Requires iText jar, downloadable from http://www.lowagie.com/iText, available for free under MPL and/or LGPL licenses.

Parameters:
outputStream - A provided java.io.OutputStream into which the PDF will be written.

printToPDFNoFonts

public void printToPDFNoFonts(java.lang.String file)
Utility method for printing the current document to a PDF (.pdf) file that relies on no PDF fonts. All text is rendered completely to pixels. Overcomes problems iText has printing certain higher-order Unicode fonts but results in much larger PDF files. NOTE 1: This method honors the current setSeparatePrintThread(boolean) setting, for which the default is true, so that by default printToPDF(file) is asynchronous and returns immediately. To ensure that the file is completely formed, you need to either call setSeparatePrintThread(false) or wait for the PrintingEventHandler printingDone event. NOTE 2: Requires iText jar, downloadable from http://www.lowagie.com/iText, available for free under MPL and/or LGPL licenses.

Parameters:
file - The file name into which the PDF file will be written (if missing, assumes ./out.pdf, if doesn't end in .pdf, will add .pdf, all folders in path must already exist).

printToPDFNoFonts

public byte[] printToPDFNoFonts()
Utility method for printing the current document to PDF stored in an in-memory byte array that relies on no PDF fonts. All text is rendered completely to pixels. Overcomes problems iText has printing certain higher-order Unicode fonts but results in much larger PDF files. NOTE 1: This method ignores the current setSeparatePrintThread(boolean) setting, and does not return until printing to the byte array is complete. NOTE 2: Requires iText jar, downloadable from http://www.lowagie.com/iText, available for free under MPL and/or LGPL licenses.


printToPDFNoFonts

public void printToPDFNoFonts(java.io.OutputStream outputStream)
Utility method for printing the current document to PDF and storing in a provided OutputStream that relies on no PDF fonts. All text is rendered completely to pixels. Overcomes problems iText has printing certain higher-order Unicode fonts but results in much larger PDF files. NOTE 1: This method honors the current setSeparatePrintThread(boolean) setting, for which the default is true, so that by default printToPDF(outputStream) is asynchronous and returns immediately. To ensure that the outputStream is completely formed, you need to either call setSeparatePrintThread(false) or wait for the PrintingEventHandler printingDone event. NOTE 2: Requires iText jar, downloadable from http://www.lowagie.com/iText, available for free under MPL and/or LGPL licenses.

Parameters:
outputStream - A provided java.io.OutputStream into which the PDF will be written.

printPDFFile

public void printPDFFile(java.lang.String file)
Utility method for printing the contents of a PDF file on the current printer (Windows only). Uses a print dialog if isPrintDialogUsed() is true, otherwise prints to the default printer if using J2Printer or to the printer specified with setPrinter if using J2Printer14. NOTE: Requires that Adobe Acrobat Reader be installed, downloadable from http://www.adobe.com/products/acrobat/readermain.html


displayPDFFile

public void displayPDFFile(java.lang.String file)
Utility method for displaying the contents of a PDF file using Adobe Acrobat Reader (Windows only). NOTE: Requires that Adobe Acrobat Reader be installed, downloadable from http://www.adobe.com/products/acrobat/readermain.html


paint

public void paint(java.awt.Graphics g)
This method is provided to paint the J2Printer bean icon in your visual builder.

Parameters:
g - Graphics context object

getPreferredSize

public java.awt.Dimension getPreferredSize()
Return preferred size of bean icon (32x32) for use in your visual builder.


getMinimumSize

public java.awt.Dimension getMinimumSize()
Return minimum size of bean icon (32x32) for use in your visual builder.


getMaximumSize

public java.awt.Dimension getMaximumSize()
Return maximum size of bean icon (32x32) for use in your visual builder.


clone

public static java.lang.Object clone(java.lang.Object obj)
Convenience method for cloning any Object in Java. Performs a "deep clone", i.e., all contained classes are recursively cloned as well. Cast the Object return value back to an Object of your type.

For example, you might copy a whole Swing object:

JTable cloneJTable = (JTable) clone(yourJTable);;

or you might clone just the Swing object's model:

TreeModel cloneTreeModel = (TreeModel) clone(yourJTree.getModel());;
JTree newJTree = new JTree();;
newJTree.setModel(cloneTreeModel);;

Parameters:
obj - Object to be cloned.
Throws:
CloneException - if unable to serialize Object.

setPageFormat

public void setPageFormat(java.awt.print.PageFormat pageFormat)
Convenience method for setting this J2Printer's "global" margins, page size, and orientation from an external PageFormat instance. Sets this J2Printer's "global" left, right, top, and bottom margins, page size, and orientation based on the values in the PageFormat instance. Note that these values may be ignored by any given Pageable with its own "local" value.

Parameters:
pageFormat - PageFormat whose values will be used to set the J2Printer margins, page size, and orientation.

getPageFormat

public java.awt.print.PageFormat getPageFormat()
Convenience method for creating a PageFormat instance based on this J2Printer's "global" margins, page size, & orientation. Each value will be based on the J2Printer's "global" values, which any given Pageable with its own "local" values might be overriding. Margins will be adjusted so they are not smaller than the current unprintable margins. Returns this J2Printer's "global" left, right, top, and bottom margins, page size, and orientation in a PageFormat instance.

Returns:
PageFormat whose values will be set based on this J2Printer's margins, page size, and orientation

makePagePanel

public javax.swing.JPanel makePagePanel(int which)
Convenience factory method to create a JPanel whose size is the same size as the body of a printable page based on the J2Printer "default" settings.

Parameters:
which - J2Pageable.FIRST (1) if page 1, or J2Pageable.REST (0) if pages 2...n.

getBodyWidth

public double getBodyWidth()
Convenience method which returns the width of the body width (printable area inside the left and right margins) based on the J2Printer "default" page settings.


getBodyHeight

public double getBodyHeight(int which)
Convenience method which returns the width of the body height (printable area inside the top and bottom margins, headers, footers, and gaps) based on the J2Printer "default" page settings.

Parameters:
which - J2Pageable.FIRST (1) if page 1, or J2Pageable.REST (0) if pages 2...n.

isCrossPlatformDialogs

public boolean isCrossPlatformDialogs()
Returns whether J2Printer is using cross platform dialogs (overridden in J2Printer14 subclass, J2Printer always returns false)


dispose

public void dispose()
Method used to dispose of all internal static J2Printer objects and set them to null, thereby freeing them up for garbage collection. These include all print preview dialog objects including user interface elements in the toolbar, page image BufferedImages, and internationalized Strings. Following the use of this method, this J2Printer instance is no longer valid for printing. It shouldn't be necessary to call this method unless you print a large number of times and create new J2Printer instances each time (and want to clean up objects created for previous J2Printer instances).


setPageable

public void setPageable(java.awt.print.Pageable pageable)
Specifies the Pageable that will be printed.

Parameters:
pageable - the Pageable that will be printed

clearPageable

public void clearPageable()
Remove all pages from this J2Printer's current Pageables list.


addPageable

public void addPageable(java.awt.print.Pageable pageable)
Add specified Pageable to end of this J2Printer's current Pageables list.


getPageable

public java.awt.print.Pageable getPageable()
Returns the Pageable that will be printed.


setDebug

public void setDebug(boolean debug)
Specifies whether stack trace and other debug information will print to System.err when errors are encountered.

Parameters:
debug - boolean specifying whether or not to print stack trace and debug information to System.err (default: true)

isDebug

public boolean isDebug()
Returns whether stack trace and other debug information will print to System.err when errors are encountered (default: true).


setPrintJobName

public void setPrintJobName(java.lang.String printJobName)
Sets the print job name that appears in the system print monitor. Using the J2Printer14 subclass, this value will be merged into the current PrintRequestAttributeSet and a JobName attribute specified using setPrinterRequestAttributeSet will set this value.

Parameters:
printJobName - String representing the print job name. Default: "J2PrinterWorks print document"

getPrintJobName

public java.lang.String getPrintJobName()
Returns the print job name for this document as set by setPrintJobName (or the JobName attribute set using setPrintRequestAttributeSet under J2Printer14)


setNumberOfCopies

public void setNumberOfCopies(int numberOfCopies)
Sets number of copies to be printed (and appear in the print dialog). This is the initial value that will appear in the print dialog, which the user might change before hitting "OK" to print. If the user changes the value in the print dialog, this change is only temporary and does not affect the numberOfCopies property. Using the J2Printer14 subclass, this value will be merged into the current PrintRequestAttributeSet and a Copies attribute specified using setPrinterRequestAttributeSet will set this value.

Parameters:
numberOfCopies - the number of copies of the document to be printed. Default: 1

getNumberOfCopies

public int getNumberOfCopies()
Returns the number of copies of the document to be printed as set by setNumberOfCopies (or the Copies attribute set using setPrintRequestAttributeSet under J2Printer14).


setPrintDialogUsed

public void setPrintDialogUsed(boolean printDialogUsed)
Sets whether to show a print dialog before printing.

Parameters:
printDialogUsed - boolean representing whether to display a print dialog before printing. Default: true

isPrintDialogUsed

public boolean isPrintDialogUsed()
Returns whether to display a print dialog before printing.


setSeparatePrintThread

public void setSeparatePrintThread(boolean separatePrintThread)
Sets whether to print from a separate thread (instead of from the same thread that called the print method).

Parameters:
separatePrintThread - boolean representing whether to print from a separate thread. Default: true

isSeparatePrintThread

public boolean isSeparatePrintThread()
Returns whether printing will be performed from a separate thread.


isPrintingUnderway

public boolean isPrintingUnderway()
Returns whether printing is underway. NOTE: Name changed from "isPrinting()" because Java added isPrinting() method to JComponent in JDK 1.6


getPageBeingPrinted

public int getPageBeingPrinted()
Returns the current page being printed (1...n).


isPrintDialogResponse

public boolean isPrintDialogResponse()
Returns the most recent user response to the print dialog box, true = "OK" or false = "cancel".


isPrintPreviewClosed

public boolean isPrintPreviewClosed()
Returns whether the print preview dialog is open or closed.


getException

public java.lang.Exception getException()
Returns the Exception (usually a java.awt.print.PrinterException) that occurred during printing.


setPrintPreviewScale

public void setPrintPreviewScale(double printPreviewScale)
Sets the starting magnification/minification scale of the print preview dialog.

Parameters:
printPreviewScale - starting scaling factor for print preview dialog (default 1.0)

getPrintPreviewScale

public double getPrintPreviewScale()
Returns the starting print preview scaling factor.


getCurrentPrintPreviewScale

public double getCurrentPrintPreviewScale()
Returns the current user-specified print preview scaling factor.


setPrintPreviewPageNumber

public void setPrintPreviewPageNumber(int pageNumber)
Sets the starting page number displayed in the print preview dialog.

Parameters:
pageNumber - starting page number displayed in the print preview dialog (default 1)

getPrintPreviewPageNumber

public int getPrintPreviewPageNumber()
Returns the starting print preview page number.


getCurrentPrintPreviewPageNumber

public int getCurrentPrintPreviewPageNumber()
Returns the current user-controlled print preview page number.


setPrintPreviewTwoPageDisplay

public void setPrintPreviewTwoPageDisplay(boolean twoPageDisplay)
Specifies whether print preview dialog starts in one or two page display mode.

Parameters:
twoPageDisplay - specifies whether print preview dialog should start in two page display mode (default true)

isPrintPreviewTwoPageDisplay

public boolean isPrintPreviewTwoPageDisplay()
Returns whether print preview dialog starts in one or two page display mode.


isCurrentPrintPreviewTwoPageDisplay

public boolean isCurrentPrintPreviewTwoPageDisplay()
Returns whether print preview dialog is currently in one or two page display mode as specified by the user.


setPrintPreviewPageSetupDialog

public void setPrintPreviewPageSetupDialog(java.awt.Dialog dialog)
Sets the page setup dialog to display when user hits "Page Setup" button in print preview dialog.

Parameters:
dialog - Dialog modal dialog to display when user hits "Page Setup" in print preview dialog, use value null to get the standard Java page setup dialog (i.e., use J2Printer.showPageSetupDialog()) (default: null)

getPrintPreviewPageSetupDialog

public java.awt.Dialog getPrintPreviewPageSetupDialog()
Returns the current print preview dialog's page setup Dialog.


setPrintPreviewCloseOnPrint

public void setPrintPreviewCloseOnPrint(int closeOnPrint)
Specifies whether and when the print preview dialog will close when user hits "Print" button.

Parameters:
closeOnPrint - int used to specify what happens to the print preview dialog when the user hits the print preview dialog "Print" button. Possibles values are: J2Printer.BEFORE to close print preview dialog immediately when user hits "Print" button (works better on some systems, e.g. Solaris), J2Printer.WAIT(default) to close print preview dialog after the print dialog appears and the user hits "OK" (or after printing begins if not using a print dialog), J2Printer.NEVER to not close print preview dialog until user manually closes the print preview dialog.

getPrintPreviewCloseOnPrint

public int getPrintPreviewCloseOnPrint()
Returns value of the print preview dialog close-on-print setting (J2Printer.BEFORE, .WAIT, or .NEVER).


setStartingPageNumber

public void setStartingPageNumber(int startingPageNumber)
Sets the starting page number, that is, the number used to number the first page of the document.

Parameters:
startingPageNumber - number used to number the first page of the document (default: 1)

getStartingPageNumber

public int getStartingPageNumber()
Returns the starting page number, that is, the number used to number the first page of the document.


setNup

public void setNup(int nup)
Sets printing to use N-up formating (N page images per physical page), where N=1, 2, 4, 6, 9, or 16, or minus these same values, where the minus sign means suppress the drawing of the page outlines.

Parameters:
nup - value where N=1, 2, 4, 6, 9, or 16, or minus these same values, where the minus sign means suppress the drawing of the page outlines. All other values are treated as N=1 (default: 1)

getNup

public int getNup()
Returns the N-up value (number of page images printed per physical page).


setHeaderFont

public void setHeaderFont(java.awt.Font font)
Sets the "global" (overall, default) Font for printing the headers for both page 1 and pages 2...n when these are specified using a String (NOTE: value cannot be changed in Free Trial Version). Used when Pageable instance value is null.

Parameters:
font - Font used for printing headers. Default: Serif, PLAIN, 10

getHeaderFont

public java.awt.Font getHeaderFont()
Returns the "global" (overall, default) Font specified for headers (same as getHeaderFont(FIRST) under assumption that header fonts on all pages are the same).


setHeaderFont

public void setHeaderFont(int which,
                          java.awt.Font font)
Sets the "global" (overall, default) Font for printing the headers for either page 1 or pages 2...n when these are specified using a String (NOTE: value cannot be changed in Free Trial Version). Used when Pageable instance value is null.

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.
font - Font used for printing headers. Default: Serif, PLAIN, 10

getHeaderFont

public java.awt.Font getHeaderFont(int which)
Returns the "global" (overall, default) Font for printing the headers for either page 1 or pages 2...n when these are specified using a String. Used when Pageable instance value is null.

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n. Default: Serif, PLAIN, 10

setFooterFont

public void setFooterFont(java.awt.Font font)
Sets the "global" (overall, default) Font for printing the footers for both page 1 and pages 2...n when these are specified using a String. Used when Pageable instance value is null.

Parameters:
font - Font used for printing headers. Default: Serif, PLAIN, 10

getFooterFont

public java.awt.Font getFooterFont()
Returns the "global" (overall, default) Font specified for footers (same as getFooterFont(FIRST) under assumption that footer fonts on all pages are the same).


setFooterFont

public void setFooterFont(int which,
                          java.awt.Font font)
Sets the "global" (overall, default) Font for printing the footers for either page 1 or pages 2...n when these are specified using a String. Used when Pageable instance value is null.

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.
font - Font used for printing footers. Default: Serif, PLAIN, 10

getFooterFont

public java.awt.Font getFooterFont(int which)
Returns the "global" (overall, default) Font for printing the footers for either page 1 or pages 2...n when these are specified using a String. Used when Pageable instance value is null.

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.

setLeftFooter

public void setLeftFooter(java.lang.Object leftFooter)
Sets the "global" (overall, default) left footer for both page 1 and pages 2...n using a String or JLabel.

Parameters:
leftFooter - String or JLabel representing the leftFooter (if null, use locale-specific date) Used when Pageable instance value is null. All occurrences of ### (3 pound signs) replaced by current page number. All occurrences of @@@ (3 at signs) replaced by total number of pages. All strings between pairs of ||| (3 vertical bars) passed to Java SimpleDateFormat class and used to format the current date & time. Default: locale-specific date
See Also:
SimpleDateFormat

getLeftFooter

public java.lang.Object getLeftFooter()
Returns the "global" (overall, default) left footer (same as getLeftFooter(FIRST)). Return Object may be String or JLabel.


setLeftFooter

public void setLeftFooter(int which,
                          java.lang.Object leftFooter)
Sets the "global" (overall, default) left footer for either page 1 or pages 2...n using a String or JLabel

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.
leftFooter - String or JLabel representing the leftFooter (if null, use locale-specific date) Used when Pageable instance value is null. Page number and data & time formatting same as for setLeftFooter. Default: locale-specific date
See Also:
setLeftFooter(java.lang.Object)

getLeftFooter

public java.lang.Object getLeftFooter(int which)
Returns the "global" (overall, default) left footer for either page 1 or pages 2...n. Return Object may be String or JLabel.

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.

setCenterFooter

public void setCenterFooter(java.lang.Object centerFooter)
Sets the "global" (overall, default) center footer for both page 1 and pages 2...n using a String or JLabel.

Parameters:
centerFooter - String or JLabel representing the centerFooter (if null, use locale-specific page number). Used when Pageable instance value is null. Page number and data & time formatting same as for setLeftFooter. Default: locale-specific page number
See Also:
setLeftFooter(java.lang.Object)

getCenterFooter

public java.lang.Object getCenterFooter()
Returns the "global" (overall, default) center footer (same as getCenterFooter(FIRST)). Return Object may be String or JLabel.


setCenterFooter

public void setCenterFooter(int which,
                            java.lang.Object centerFooter)
Sets the "global" (overall, default) center footer for either page 1 or pages 2...n using a String or JLabel

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.
centerFooter - String or JLabel representing the centerFooter (if null, use locale-specific page number). Used when Pageable instance value is null. Page number and data & time formatting same as for setLeftFooter. Default: locale-specific page number
See Also:
setLeftFooter(java.lang.Object)

getCenterFooter

public java.lang.Object getCenterFooter(int which)
Returns the "global" (overall, default) center footer for either page 1 or pages 2...n. Return Object may be String or JLabel.

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.

setRightFooter

public void setRightFooter(java.lang.Object rightFooter)
Sets the "global" (overall, default) right footer for both page 1 and pages 2...n using a String or JLabel.

Parameters:
rightFooter - String or JLabel representing the rightFooter (if null, use locale-specific time). Used when Pageable instance value is null. Page number and data & time formatting same as for setLeftFooter. Default: local-specific time
See Also:
setLeftFooter(java.lang.Object)

getRightFooter

public java.lang.Object getRightFooter()
Returns the "global" (overall, default) right footer (same as getRightFooter(FIRST)). Return Object may be String or JLabel.


setRightFooter

public void setRightFooter(int which,
                           java.lang.Object rightFooter)
Sets the "global" (overall, default) right footer for either page 1 or pages 2...n using a String or JLabel.

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.
rightFooter - String or JLabel representing the rightFooter (if null, use locale-specific time). Used when Pageable instance value is null. Page number and data & time formatting same as for setLeftFooter. Default: locale-specific time
See Also:
setLeftFooter(java.lang.Object)

getRightFooter

public java.lang.Object getRightFooter(int which)
Returns the "global" (overall, default) right footer for either page 1 or pages 2...n. Return Object may be String or JLabel.

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.

setLeftHeader

public void setLeftHeader(java.lang.Object leftHeader)
Sets the "global" (overall, default) left header for both page 1 and pages 2...n using a String or JLabel. (NOTE: value cannot be changed in Free Trial Version).

Parameters:
leftHeader - String or JLabel representing the leftHeader Used when Pageable instance value is null. All occurrences of ### (3 pound signs) replaced by current page number. All occurrences of @@@ (3 at signs) replaced by total number of pages. All strings between pairs of ||| (3 vertical bars) passed to Java SimpleDateFormat class and used to format the current date & time. Default: Wildcrest Associates copyright notice
See Also:
SimpleDateFormat

getLeftHeader

public java.lang.Object getLeftHeader()
Returns the "global" (overall, default) left header (same as getLeftHeader(FIRST)). Return Object may be String or JLabel.


setLeftHeader

public void setLeftHeader(int which,
                          java.lang.Object leftHeader)
Sets the "global" (overall, default) left header for either page 1 or pages 2...n using a String or JLabel (NOTE: value cannot be changed in Free Trial Version).

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.
leftHeader - String or JLabel representing the leftHeader. Used when Pageable instance value is null. Page number and data & time formatting same as for setLeftHeader. Default: Wildcrest Associates copyright notice
See Also:
setLeftHeader(java.lang.Object)

getLeftHeader

public java.lang.Object getLeftHeader(int which)
Returns the "global" (overall, default) left header for either page 1 or pages 2...n. Return Object may be String or JLabel.

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.

setCenterHeader

public void setCenterHeader(java.lang.Object centerHeader)
Sets the "global" (overall, default) center header for both page 1 and pages 2...n using a String or JLabel (NOTE: value cannot be changed in Free Trial Version).

Parameters:
centerHeader - String or JLabel representing the centerHeader. Used when Pageable instance value is null. Page number and data & time formatting same as for setLeftHeader. Default: empty String
See Also:
setLeftHeader(java.lang.Object)

getCenterHeader

public java.lang.Object getCenterHeader()
Returns the "global" (overall, default) center header (same as getCenterHeader(FIRST)). Return Object may be String or JLabel.


setCenterHeader

public void setCenterHeader(int which,
                            java.lang.Object centerHeader)
Sets the "global" (overall, default) center header for either page 1 or pages 2...n using a String or JLabel (NOTE: value cannot be changed in Free Trial Version).

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.
centerHeader - String or JLabel representing the centerHeader. Used when Pageable instance value is null. Page number and data & time formatting same as for setLeftHeader. Default: empty String
See Also:
setLeftHeader(java.lang.Object)

getCenterHeader

public java.lang.Object getCenterHeader(int which)
Returns the "global" (overall, default) center header for either page 1 or pages 2...n. Return Object may be String or JLabel.

Parameters:
which - int = J2Printer.FIRST (1) if page 1, or = .REST (0) if pages 2...n.

setRightHeader

public void setRightHeader(java.lang.Object rightHeader)
Sets the "global" (overall, default) right header for both page 1 and pages 2...n using a String or JLabel (NOTE: value cannot be changed in Free Trial Version).

Parameters:
rightHeader - String or JLabel representing the rightHeader. Used when Pageable instance value is null. Page number and data & time formatting same as for setLeftHeader. Default: Wildcrest Associates copyright notice
See Also:
setLeftHeader(java.lang.Object)

getRightHeader

public java.lang.Object getRightHeader()
Returns the "global" (overall, default) right header (same as getRightHeader(FIRST)). Return Object may be String or JLabel.


setRightHeader

public void setRightHeader(int which,
                           java.lang.Object rightHeader)
Sets the "global" (overall, default) right header for either page 1 or pages 2...n using a String or JLabel (NOTE: value cannot be changed in Free Trial Version).

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.
rightHeader - String or JLabel representing the rightHeader. Used when Pageable instance value is null. Page number and data & time formatting same as for setLeftHeader. Default: Wildcrest Associates copyright notice
See Also:
setLeftHeader(java.lang.Object)

getRightHeader

public java.lang.Object getRightHeader(int which)
Returns the "global" (overall, default) right header for either page 1 or pages 2...n. Return Object may be String or JLabel.

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.

setHeaderStyle

public void setHeaderStyle(int style)
Sets the "global" (overall, default) header style for both page 1 and pages 2...n (NOTE: value cannot be changed in Free Trial Version).

Parameters:
style - J2Printer.BOX or .LINE or .NONE. Used when Pageable instance value is negative (e.g., GLOBAL). Default: BOX

getHeaderStyle

public int getHeaderStyle()
Returns the "global" (overall, default) header style (returns answer for page 1).


setHeaderStyle

public void setHeaderStyle(int which,
                           int style)
Sets the "global" (overall, default) header style for either page 1 or pages 2...n (NOTE: value cannot be changed in Free Trial Version).

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.
style - J2Printer.BOX or .LINE or .NONE. Used when Pageable instance value is negative (e.g., GLOBAL). Default: BOX

getHeaderStyle

public int getHeaderStyle(int which)
Returns the "global" (overall, default) header style for either page 1 or pages 2...n.

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.

setFooterStyle

public void setFooterStyle(int style)
Sets "global" (overall, default) footer style for both page 1 and pages 2...n.

Parameters:
style - J2Printer.BOX or .LINE or .NONE. Used when Pageable instance value is negative (e.g., GLOBAL). Default: BOX

getFooterStyle

public int getFooterStyle()
Returns "global" (overall, default) footer style (returns answer for page 1).


setFooterStyle

public void setFooterStyle(int which,
                           int style)
Sets "global" (overall, default) footer style for either page 1 or pages 2...n.

Parameters:
which - J2Printer.FIRST (1) if page 1, or J2Printer.REST (0) if pages 2...n.
style - J2Printer.BOX or .LINE or .NONE. Used when Pageable instance value is negative (e.g., GLOBAL). Default: BOX

getFooterStyle

public int getFooterStyle(int which)
Returns "global" (overall, default) footer style for either page 1 or pages 2...n.

Parameters:
which - J2Printer.FIRST (1) if page 1, or REST (0) if pages 2...n.

clearHeaders

public void clearHeaders()
Clears all the "global" (overall, default) headers for both page 1 and pages 2...n to the empty String "" (NOTE: value cannot be changed in Free Trial Version).


clearHeaders

public void clearHeaders(int which)
Clears all the "global" (overall, default) headers for either page 1 of pages 2...n to the empty String "" (NOTE: value cannot be changed in Free Trial Version).

Parameters:
which - int = FIRST (1) if page 1, or = REST (0) if pages 2...n.

clearFooters

public void clearFooters()
Clears all the "global" (overall, default) footers for both page 1 and pages 2...n to the empty String "".


clearFooters

public void clearFooters(int which)
Clears all the "global" (overall, default) footers for either page 1 of pages 2...n to the empty String "".

Parameters:
which - int = FIRST (1) if page 1, or = REST (0) if pages 2...n.

setLeftMargin

public void setLeftMargin(double leftMargin)
Sets the "global" (overall, default) left margin in inches from the edge of the page (when viewing content). Actual margin will not be less than the unprintable left margin.

Parameters:
leftMargin - double representing left margin in inches. Used when Pageable instance value is negative (e.g., GLOBAL). Default: 0.0

getLeftMargin

public double getLeftMargin()
Returns the "global" (overall, default) left margin.


setRightMargin

public void setRightMargin(double rightMargin)
Sets the "global" (overall, default) right margin in inches from the edge of the page (when viewing content). Actual margin will not be less than the unprintable right margin.

Parameters:
rightMargin - double representing right margin in inches. Used when Pageable instance value is negative (e.g., GLOBAL). Default: 0.0

getRightMargin

public double getRightMargin()
Returns the "global" (overall, default) right margin.


setTopMargin

public void setTopMargin(double topMargin)
Sets the "global" (overall, default) top margin above header in inches from the edge of the page when viewing content). Actual margin will not be less than the unprintable top margin.

Parameters:
topMargin - double representing top margin above header in inches. Used when Pageable instance value is negative (e.g., GLOBAL). Default: 0.0

getTopMargin

public double getTopMargin()
Returns the "global" (overall, default) top margin.


setBottomMargin

public void setBottomMargin(double bottomMargin)
Sets the "global" (overall, default) bottom margin below footer in inches from the edge of the page (when viewing content). Actual margin will not be less than the unprintable bottom margin.

Parameters:
bottomMargin - double representing bottom margin below footer in inches. Used when Pageable instance value is negative (e.g., GLOBAL). Default: 0.0

getBottomMargin

public double getBottomMargin()
Returns the "global" (overall, default) bottom margin.


setGapBelowHeader

public void setGapBelowHeader(double gapBelowHeader)
Sets the "global" (overall, default) gap between the bottom of the header and the top of the first line of body in inches.

Parameters:
gapBelowHeader - double representing gap between the header and first line of body. Used when Pageable instance value is negative (e.g., GLOBAL). Default 0.125

getGapBelowHeader

public double getGapBelowHeader()
Returns the "global" (overall, default) gap between the header and first line in inches.


setGapAboveFooter

public void setGapAboveFooter(double gapAboveFooter)
Sets the "global" (overall, default) gap between the bottom of the last line of body and the top of the footer in inches.

Parameters:
gapAboveFooter - double representing gap between the last line of body and the footer in inches. Used when Pageable instance value is negative (e.g., GLOBAL). Default 0.125

getGapAboveFooter

public double getGapAboveFooter()
Returns the "global" (overall, default) gap between the last line and the footer in inches.


setScale

public void setScale(double scale)
Sets "global" (overall, default) magnification or minification scaling factor for printing.

Parameters:
scale - double scaling factor for printing. Default: 1.0

getScale

public double getScale()
Returns the "global" (overall, default) magnification or minification scaling factor for printing.


setOrientation

public void setOrientation(int orientation)
Sets "global" (overall, default) page orientation (causes corresponding reordering of unprintable margin settings)

Parameters:
orientation - J2Printer.PORTRAIT or .LANDSCAPE or .REVERSE_LANDSCAPE used when Pageable instance value is negative (e.g., GLOBAL). (same as PageFormat.PORTRAIT, etc.). Default: PORTRAIT

getOrientation

public int getOrientation()
Returns the "global" (overall, default) page orientation (PORTRAIT, LANDSCAPE, or REVERSE_LANDSCAPE).


setPaperSize

public void setPaperSize(double paperW,
                         double paperH)
Sets the "global" (overall, default) paper width and height in 1/72nds of an inch when paper viewed in PORTRAIT.

Parameters:
paperW - paper width in 1/72nds of an inch ("points") when viewed in PORTRAIT
paperH - paper height in 1/72nds of an inch ("points") when viewed in PORTRAIT

getPaperWidth

public double getPaperWidth()
Returns the "global" (overall, default) paper width in 1/72nds of an inch with paper viewed in PORTRAIT.


getPaperHeight

public double getPaperHeight()
Returns the "global" (overall, default) paper height in 1/72nds of an inch with paper viewed in PORTRAIT.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a PropertyChangeListener for this component


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a PropertyChangeListener for this component


fire

protected void fire(java.lang.String propertyName)
Fire property change event for this component


getVersion

public static java.lang.String getVersion()
Returns the J2PrinterWorks version number.


main

public static void main(java.lang.String[] args)
Double click on J2PrinterWorks.jar to find out its version number and date.