public class DocumentPrinting
extends java.lang.Object
implements java.awt.print.Printable
new DocumentPrinting().print(YourJTextComponent);Reminder: Just make sure there is a text on your component ;P
Author : Jan Michael Soan WebSite: http://www.jmsoan.com Date : 04/17/2004 Time : 2:20 PMFound on Toolbox (Terms of Use).
Constructor and Description |
---|
DocumentPrinting()
Initializes the printing.
|
Modifier and Type | Method and Description |
---|---|
javax.swing.text.Document |
getDocument()
Returns the document to print.
|
boolean |
getScaleWidthToFit()
Returns whether the width is to be scaled.
|
int |
print(java.awt.Graphics graphics,
java.awt.print.PageFormat pageFormat,
int pageIndex)
Prints the page.
|
void |
print(javax.swing.JTextPane pane)
Prints the document in the JTextPane.
|
void |
printDialog()
Shows the print dialog.
|
void |
setContentType(java.lang.String type)
Sets the content type.
|
void |
setDocument(javax.swing.JTextPane pane)
Sets the document from the given JTextPane.
|
void |
setDocument(java.lang.String type,
javax.swing.text.Document document)
Sets the document and the according content type.
|
void |
setScaleWidthToFit(boolean scaleWidth)
Sets whether to scale the width to fit.
|
public int print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
print
in interface java.awt.print.Printable
graphics
- the graphics contextpageFormat
- the format of the pagepageIndex
- the page indexPrintable.NO_SUCH_PAGE
,
Printable.PAGE_EXISTS
public void print(javax.swing.JTextPane pane)
pane
- the document to printpublic void printDialog()
public void setContentType(java.lang.String type)
type
- the content typepublic javax.swing.text.Document getDocument()
public void setDocument(javax.swing.JTextPane pane)
pane
- the JTextPane to get the document frompublic void setDocument(java.lang.String type, javax.swing.text.Document document)
type
- the content typedocument
- the document to printpublic void setScaleWidthToFit(boolean scaleWidth)
scaleWidth
- if true then the width will be scaledpublic boolean getScaleWidthToFit()