All Packages Class Hierarchy This Package Previous Next Index
Class com.wildcrest.JTextPrinter
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----com.sun.java.swing.JComponent
|
+----com.wildcrest.JTextPrinter
- public class JTextPrinter
- extends JComponent
(C) Copyright 1999, Wildcrest Associates (http://www.wildcrest.com).
All rights reserved.
A Swing (JFC) component for printing multipage rich text documents.
Prints the contents of any JTextPane (any StyledDocument) including embedded graphics and
components. Supports pagination, headers, footers, margins, date and page numbering, multiple
columns with optional title section, page breaks, page ranges, and print monitor job name control.
-
JTextPrinter()
- Construct a TextPrinter object
-
addPropertyChangeListener(PropertyChangeListener)
-
-
getBottomMargin()
- Returns the bottom margin of the document.
-
getCenterFooter()
- Returns the center footer of the document.
-
getCenterHeader()
- Returns the center header of the document.
-
getGapAboveFooter()
- Returns the gap between the last line and the footer in inches.
-
getGapBelowHeader()
- Returns the gap between the header and first line in inches.
-
getGapBetweenColumns()
- Returns size of gap between columns in inches.
-
getHeaderFooterFont()
- Returns the font specified for headers and footers.
-
getLeftFooter()
- Returns the left footer of the document.
-
getLeftHeader()
- Returns the left header of the document.
-
getLeftMargin()
- Returns the left margin of the document.
-
getMainPane()
- Returns the JTextPane containing the main body of the document to be printed.
-
getMaximumColumnWidth()
- Returns maximum column width in pixels (negative value means no limit).
-
getNumberOfColumns()
- Returns number of columns per page.
-
getPageRange()
- Returns the page range of pages to be printed.
-
getPrintJobName()
- Returns the print job name for this document.
-
getRightFooter()
- Returns the right footer of the document.
-
getRightHeader()
- Returns the right header of the document.
-
getRightMargin()
- Returns the right margin of the document.
-
getTitlePane()
- Returns the JTextPane containing an initial title section to be printed in single column mode.
-
getTopMargin()
- Returns the top margin of the document.
-
isBoxAroundFooter()
- Returns whether a box will be drawn around the footer.
-
isBoxAroundHeader()
- Returns whether a box will be drawn around the header.
-
isLineAboveFooter()
- Returns whether a line will be drawn above the footer.
-
isLineBelowHeader()
- Returns whether a line will be drawn below the header.
-
paint(Graphics)
-
-
print()
- Method for printing the currently specified single column title section (specified using setTitlePane)
followed by the currently specified single or multiple column main document (specified using setMainPane)
-
print(JTextPane)
- Method for printing the StyledDocument of a JTextPane as the main document with no title section
-
print(JTextPane, JTextPane)
- Method for printing the StyledDocument of a first JTextPane as a single column title section followed
by the StyledDocument of a second JTextPane as the main (single or multiple column) document
-
removePropertyChangeListener(PropertyChangeListener)
-
-
setBottomMargin(double)
- Sets the bottom margin below footer in inches.
-
setBoxAroundFooter(boolean)
- Sets whether to draw a box around the footerr.
-
setBoxAroundHeader(boolean)
- Sets whether to draw a box around the header.
-
setCenterFooter(String)
- Sets the center footer of the document.
-
setCenterHeader(String)
- Sets the center header of the document.
-
setGapAboveFooter(double)
- Sets the gap between the last line of text and the footer in inches.
-
setGapBelowHeader(double)
- Sets the gap between the header and first line of text in inches.
-
setGapBetweenColumns(double)
- Sets gap between columns in inches
-
setHeaderFooterFont(Font)
- Sets the font for printing the headers and footers of the document.
-
setLeftFooter(String)
- Sets the left footer of the document.
-
setLeftHeader(String)
- Sets the left header of the document.
-
setLeftMargin(double)
- Sets the left margin in inches.
-
setLineAboveFooter(boolean)
- Sets whether to draw a line above the footerr.
-
setLineBelowHeader(boolean)
- Sets whether to draw a line below the header.
-
setMainPane(JTextPane)
- Sets the JTextPane containing the main body of the document to be printed.
-
setMaximumColumnWidth(int)
- Sets maximum column width in pixels
-
setNumberOfColumns(int)
- Sets number of columns per page.
-
setPageRange(String)
- Sets the page range of pages to be printed.
-
setPrintJobName(String)
- Sets the print job name that appears in the system print monitor.
-
setRightFooter(String)
- Sets the right footer of the document.
-
setRightHeader(String)
- Sets the right header of the document.
-
setRightMargin(double)
- Sets the right margin in inches.
-
setTitlePane(JTextPane)
- Sets the (optional) JTextPane containing a title section to be printed in single column mode
before the main document.
-
setTopMargin(double)
- Sets the top margin above header in inches.
JTextPrinter
public JTextPrinter()
- Construct a TextPrinter object
setMainPane
public void setMainPane(JTextPane mainPane)
- Sets the JTextPane containing the main body of the document to be printed.
- Parameters:
- mainPane - the JTextPane containing the main body of the document to be printed
getMainPane
public synchronized JTextPane getMainPane()
- Returns the JTextPane containing the main body of the document to be printed.
setTitlePane
public void setTitlePane(JTextPane titlePane)
- Sets the (optional) JTextPane containing a title section to be printed in single column mode
before the main document. Used for specifying an optional single column title section or cover page
of a multiple column document.
- Parameters:
- titlePane - a JTextPane containing an initial title section to be printed in single column mode
getTitlePane
public synchronized JTextPane getTitlePane()
- Returns the JTextPane containing an initial title section to be printed in single column mode.
setHeaderFooterFont
public void setHeaderFooterFont(Font font)
- Sets the font for printing the headers and footers of the document.
- Parameters:
- font - font used for printing headers and footers of document. Default: Serif, PLAIN, 10
NOTE: value cannot be changed in free version.
getHeaderFooterFont
public synchronized Font getHeaderFooterFont()
- Returns the font specified for headers and footers.
setLeftFooter
public void setLeftFooter(String leftFooter)
- Sets the left footer of the document.
- Parameters:
- leftFooter - string representing the leftFooter.
All occurrences of ### (3 pound signs) replaced by current page number.
All strings between pairs of ||| (3 vertical bars) passed to Java SimpleDateFormat class
and used to format the current date & time. Default: Page ###
- See Also:
- SimpleDateFormat
getLeftFooter
public synchronized String getLeftFooter()
- Returns the left footer of the document.
setCenterFooter
public void setCenterFooter(String centerFooter)
- Sets the center footer of the document.
- Parameters:
- centerFooter - string representing the center footer.
Page number and data & time formatting same as for setLeftFooter.
Default: |||EEE, MMM d, yyyy|||
getCenterFooter
public synchronized String getCenterFooter()
- Returns the center footer of the document.
setRightFooter
public void setRightFooter(String rightFooter)
- Sets the right footer of the document.
- Parameters:
- rightFooter - string representing the right footer.
Page number and data & time formatting same as for setLeftFooter.
Default: |||hh:mm:ss a zzz|||
getRightFooter
public synchronized String getRightFooter()
- Returns the right footer of the document.
setLeftHeader
public void setLeftHeader(String leftHeader)
- Sets the left header of the document.
- Parameters:
- leftHeader - string representing the left header
Page number and data & time formatting same as for setLeftFooter.
Default: JTextPrinter Wildcrest Associates copyright notice
NOTE: value cannot be changed in free version.
getLeftHeader
public synchronized String getLeftHeader()
- Returns the left header of the document.
setCenterHeader
public void setCenterHeader(String centerHeader)
- Sets the center header of the document.
- Parameters:
- centerHeader - string representing the center header
Page number and data & time formatting same as for setLeftFooter.
Default: empty
NOTE: value cannot be changed in free version.
getCenterHeader
public synchronized String getCenterHeader()
- Returns the center header of the document.
setRightHeader
public void setRightHeader(String rightHeader)
- Sets the right header of the document.
- Parameters:
- rightHeader - string representing the right header
Page number and data & time formatting same as for setLeftFooter.
Default: JTextPrinter Wildcrest Associates copyright notice
NOTE: value cannot be changed in free version.
getRightHeader
public synchronized String getRightHeader()
- Returns the right header of the document.
setLeftMargin
public void setLeftMargin(double leftMargin)
- Sets the left margin in inches.
- Parameters:
- leftMargin - double representing left margin in inches.
Default: JDK and OS specific (see documentation)
getLeftMargin
public synchronized double getLeftMargin()
- Returns the left margin of the document.
setRightMargin
public void setRightMargin(double rightMargin)
- Sets the right margin in inches.
- Parameters:
- rightMargin - double representing right margin in inches.
Default: JDK and OS specific (see documentation)
getRightMargin
public synchronized double getRightMargin()
- Returns the right margin of the document.
setTopMargin
public void setTopMargin(double topMargin)
- Sets the top margin above header in inches.
- Parameters:
- topMargin - double representing top margin above header in inches.
Default: JDK and OS specific (see documentation)
getTopMargin
public synchronized double getTopMargin()
- Returns the top margin of the document.
setBottomMargin
public void setBottomMargin(double bottomMargin)
- Sets the bottom margin below footer in inches.
- Parameters:
- bottomMargin - double representing bottom margin below footer in inches.
Default JDK and OS specific (see documentation)
getBottomMargin
public synchronized double getBottomMargin()
- Returns the bottom margin of the document.
setGapBelowHeader
public void setGapBelowHeader(double gapBelowHeader)
- Sets the gap between the header and first line of text in inches.
- Parameters:
- gapBelowHeader - double representing gap between the header and first line of text. Default 0.25
getGapBelowHeader
public synchronized double getGapBelowHeader()
- Returns the gap between the header and first line in inches.
setGapAboveFooter
public void setGapAboveFooter(double gapAboveFooter)
- Sets the gap between the last line of text and the footer in inches.
- Parameters:
- gapAboveFooter - double representing gap between the last line of text and the footer in inches.
Default 0.125
getGapAboveFooter
public synchronized double getGapAboveFooter()
- Returns the gap between the last line and the footer in inches.
setPrintJobName
public void setPrintJobName(String printJobName)
- Sets the print job name that appears in the system print monitor.
- Parameters:
- printJobName - string representing the print job name. Default: "JTextPrinter print document"
getPrintJobName
public synchronized String getPrintJobName()
- Returns the print job name for this document.
setPageRange
public void setPageRange(String pageRange)
- Sets the page range of pages to be printed. Page ranges specified using same syntax as Microsoft Word,
i.e., values separated by commas, values may be a single page number or two page numbers separated by
a hyphen. Examples: 1,3,5 1-3,6,8-12 0-1000 Empty string means print all pages. Pages print in
order regardless of order in page range.
- Parameters:
- pageRange - string representing the page range of pages to be printed. Default: "" (= all)
getPageRange
public synchronized String getPageRange()
- Returns the page range of pages to be printed.
setLineBelowHeader
public void setLineBelowHeader(boolean lineBelowHeader)
- Sets whether to draw a line below the header.
- Parameters:
- lineBelowHeader - boolean representing whether to draw a line below the header. Default: false
isLineBelowHeader
public synchronized boolean isLineBelowHeader()
- Returns whether a line will be drawn below the header.
setLineAboveFooter
public void setLineAboveFooter(boolean lineAboveFooter)
- Sets whether to draw a line above the footerr.
- Parameters:
- lineAboveFooter - boolean representing whether to draw a line above the footer. Default: true
isLineAboveFooter
public synchronized boolean isLineAboveFooter()
- Returns whether a line will be drawn above the footer.
setBoxAroundHeader
public void setBoxAroundHeader(boolean boxAroundHeader)
- Sets whether to draw a box around the header.
- Parameters:
- boxAroundHeader - boolean representing whether to draw a box around the header. Default: true
isBoxAroundHeader
public synchronized boolean isBoxAroundHeader()
- Returns whether a box will be drawn around the header.
setBoxAroundFooter
public void setBoxAroundFooter(boolean boxAroundFooter)
- Sets whether to draw a box around the footerr.
- Parameters:
- boxAroundFooter - boolean representing whether to draw a box around the footer. Default: false
isBoxAroundFooter
public synchronized boolean isBoxAroundFooter()
- Returns whether a box will be drawn around the footer.
setNumberOfColumns
public void setNumberOfColumns(int numberOfColumns)
- Sets number of columns per page.
- Parameters:
- numberOfColumns - int representing how many columns per page in main document. Default: 1
getNumberOfColumns
public synchronized int getNumberOfColumns()
- Returns number of columns per page.
setGapBetweenColumns
public void setGapBetweenColumns(double gapBetweenColumns)
- Sets gap between columns in inches
- Parameters:
- gapBetweenColumns - double representing size of gap between columns in inches. Default: 0.1
getGapBetweenColumns
public synchronized double getGapBetweenColumns()
- Returns size of gap between columns in inches.
setMaximumColumnWidth
public void setMaximumColumnWidth(int maximumColumnWidth)
- Sets maximum column width in pixels
- Parameters:
- maximumColumnWidth - int representing maximum column width in pixels
(negative value means no limit). Default: -1
getMaximumColumnWidth
public synchronized int getMaximumColumnWidth()
- Returns maximum column width in pixels (negative value means no limit).
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener l)
- Overrides:
- addPropertyChangeListener in class JComponent
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener l)
- Overrides:
- removePropertyChangeListener in class JComponent
print
public void print(JTextPane mainPane)
- Method for printing the StyledDocument of a JTextPane as the main document with no title section
- Parameters:
- mainPane - JTextPane whose StyledDocument is to be printed
print
public void print(JTextPane titlePane,
JTextPane mainPane)
- Method for printing the StyledDocument of a first JTextPane as a single column title section followed
by the StyledDocument of a second JTextPane as the main (single or multiple column) document
- Parameters:
- titlePane - JTextPane whose StyledDocument is to be printed as the title section
- mainPane - JTextPane whose StyledDocument is to be printed as the main document
print
public void print()
- Method for printing the currently specified single column title section (specified using setTitlePane)
followed by the currently specified single or multiple column main document (specified using setMainPane)
paint
public synchronized void paint(Graphics g)
- Overrides:
- paint in class JComponent
All Packages Class Hierarchy This Package Previous Next Index