public class DocumentPrinting extends Object implements 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).
NO_SUCH_PAGE, PAGE_EXISTS| Constructor and Description |
|---|
DocumentPrinting()
Initializes the printing.
|
| Modifier and Type | Method and Description |
|---|---|
Document |
getDocument()
Returns the document to print.
|
boolean |
getScaleWidthToFit()
Returns whether the width is to be scaled.
|
int |
print(Graphics graphics,
PageFormat pageFormat,
int pageIndex)
Prints the page.
|
void |
print(JTextPane pane)
Prints the document in the JTextPane.
|
void |
printDialog()
Shows the print dialog.
|
void |
setContentType(String type)
Sets the content type.
|
void |
setDocument(JTextPane pane)
Sets the document from the given JTextPane.
|
void |
setDocument(String type,
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(Graphics graphics, PageFormat pageFormat, int pageIndex)
print in interface Printablegraphics - the graphics contextpageFormat - the format of the pagepageIndex - the page indexPrintable.NO_SUCH_PAGE,
Printable.PAGE_EXISTSpublic void print(JTextPane pane)
pane - the document to printpublic void printDialog()
public void setContentType(String type)
type - the content typepublic Document getDocument()
public void setDocument(JTextPane pane)
pane - the JTextPane to get the document frompublic void setDocument(String type, 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()
Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.