Package weka.gui
Class DocumentPrinting
java.lang.Object
weka.gui.DocumentPrinting
- All Implemented Interfaces:
Printable
DocumentPrinting is a class that lets you print documents on
the fly for free ;) Printing in JDK 1.2 - 1.5 is hard.
With this, you just simply call it in your application
and add your text component like JTextPane:
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).
- Author:
- Jan Michael Soan (original code), FracPete (fracpete at waikato dot ac dot nz)
-
Field Summary
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the document to print.boolean
Returns whether the width is to be scaled.int
print
(Graphics graphics, PageFormat pageFormat, int pageIndex) Prints the page.void
Prints the document in the JTextPane.void
Shows the print dialog.void
setContentType
(String type) Sets the content type.void
setDocument
(String type, Document document) Sets the document and the according content type.void
setDocument
(JTextPane pane) Sets the document from the given JTextPane.void
setScaleWidthToFit
(boolean scaleWidth) Sets whether to scale the width to fit.
-
Constructor Details
-
DocumentPrinting
public DocumentPrinting()Initializes the printing.
-
-
Method Details
-
print
Prints the page. -
print
Prints the document in the JTextPane.- Parameters:
pane
- the document to print
-
printDialog
public void printDialog()Shows the print dialog. -
setContentType
Sets the content type.- Parameters:
type
- the content type
-
getDocument
Returns the document to print.- Returns:
- the document or null
-
setDocument
Sets the document from the given JTextPane.- Parameters:
pane
- the JTextPane to get the document from
-
setDocument
Sets the document and the according content type.- Parameters:
type
- the content typedocument
- the document to print
-
setScaleWidthToFit
public void setScaleWidthToFit(boolean scaleWidth) Sets whether to scale the width to fit.- Parameters:
scaleWidth
- if true then the width will be scaled
-
getScaleWidthToFit
public boolean getScaleWidthToFit()Returns whether the width is to be scaled.- Returns:
- true if scaled
-