Package weka.gui

Class DocumentPrinting

java.lang.Object
weka.gui.DocumentPrinting
All Implemented Interfaces:
Printable

public class DocumentPrinting extends Object implements 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 PM 
 
Found on Toolbox (Terms of Use).
Author:
Jan Michael Soan (original code), FracPete (fracpete at waikato dot ac dot nz)
  • Constructor Details

    • DocumentPrinting

      public DocumentPrinting()
      Initializes the printing.
  • Method Details

    • print

      public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
      Prints the page.
      Specified by:
      print in interface Printable
      Parameters:
      graphics - the graphics context
      pageFormat - the format of the page
      pageIndex - the page index
      Returns:
      either NO_SUCH_PAGE or PAGE_EXISTS
      See Also:
    • print

      public void print(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(String type)
      Sets the content type.
      Parameters:
      type - the content type
    • getDocument

      public Document getDocument()
      Returns the document to print.
      Returns:
      the document or null
    • setDocument

      public void setDocument(JTextPane pane)
      Sets the document from the given JTextPane.
      Parameters:
      pane - the JTextPane to get the document from
    • setDocument

      public void setDocument(String type, Document document)
      Sets the document and the according content type.
      Parameters:
      type - the content type
      document - 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