Package weka.gui
Class DocumentPrinting
- java.lang.Object
-
- weka.gui.DocumentPrinting
-
- All Implemented Interfaces:
java.awt.print.Printable
public class DocumentPrinting extends java.lang.Object implements java.awt.print.PrintableDocumentPrinting 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 ;PAuthor : Jan Michael Soan WebSite: http://www.jmsoan.com Date : 04/17/2004 Time : 2:20 PM
Found on Toolbox (Terms of Use).- Author:
- Jan Michael Soan (original code), FracPete (fracpete at waikato dot ac dot nz)
-
-
Constructor Summary
Constructors Constructor Description DocumentPrinting()Initializes the printing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.swing.text.DocumentgetDocument()Returns the document to print.booleangetScaleWidthToFit()Returns whether the width is to be scaled.intprint(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)Prints the page.voidprint(javax.swing.JTextPane pane)Prints the document in the JTextPane.voidprintDialog()Shows the print dialog.voidsetContentType(java.lang.String type)Sets the content type.voidsetDocument(java.lang.String type, javax.swing.text.Document document)Sets the document and the according content type.voidsetDocument(javax.swing.JTextPane pane)Sets the document from the given JTextPane.voidsetScaleWidthToFit(boolean scaleWidth)Sets whether to scale the width to fit.
-
-
-
Method Detail
-
print
public int print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)Prints the page.- Specified by:
printin interfacejava.awt.print.Printable- Parameters:
graphics- the graphics contextpageFormat- the format of the pagepageIndex- the page index- Returns:
- either NO_SUCH_PAGE or PAGE_EXISTS
- See Also:
Printable.NO_SUCH_PAGE,Printable.PAGE_EXISTS
-
print
public void print(javax.swing.JTextPane pane)
Prints the document in the JTextPane.- Parameters:
pane- the document to print
-
printDialog
public void printDialog()
Shows the print dialog.
-
setContentType
public void setContentType(java.lang.String type)
Sets the content type.- Parameters:
type- the content type
-
getDocument
public javax.swing.text.Document getDocument()
Returns the document to print.- Returns:
- the document or null
-
setDocument
public void setDocument(javax.swing.JTextPane pane)
Sets the document from the given JTextPane.- Parameters:
pane- the JTextPane to get the document from
-
setDocument
public void setDocument(java.lang.String type, javax.swing.text.Document document)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
-
-