Package com.iizix

Class ComponentPrinter

  • All Implemented Interfaces:
    java.awt.print.Printable

    public class ComponentPrinter
    extends java.lang.Object
    implements java.awt.print.Printable
    The component printer class will print a "frame" window or a component inside a "frame". This "frame" is really a container and not the frame itself.
    Author:
    Christopher Mindus
    • Field Summary

      • Fields inherited from interface java.awt.print.Printable

        NO_SUCH_PAGE, PAGE_EXISTS
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int print​(java.awt.Graphics g, java.awt.print.PageFormat pf, int pageIndex)
      Prints the requested component using Java2D.
      static boolean render​(java.awt.Component componentToPrint, boolean useDefault)
      Renders a "frame" window.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ComponentPrinter

        public ComponentPrinter()
    • Method Detail

      • render

        public static boolean render​(java.awt.Component componentToPrint,
                                     boolean useDefault)
        Renders a "frame" window.
        Parameters:
        componentToPrint - Component to print.
        useDefault - Flag to use the default printer assigned, false to ask user.
        Returns:
        true for success, false for failure.
      • print

        public int print​(java.awt.Graphics g,
                         java.awt.print.PageFormat pf,
                         int pageIndex)
        Prints the requested component using Java2D. For some reason it gets called twice with pageIndex=0 in some implementations and some JDK's.
        Specified by:
        print in interface java.awt.print.Printable