Class PrintPreview

All Implemented Interfaces:
ImageObserver, MenuContainer, Printable, Serializable, Accessible

public class PrintPreview extends JPanel implements Printable
Presents the preview of the specified printable component.
See Also:
  • Constructor Details

    • PrintPreview

      public PrintPreview(JComponent sub, HFPageFormat pf, int pi)
      Creates an object of print preview.
  • Method Details

    • setLeftHeaderText

      public void setLeftHeaderText(String header)
      The header will be printed at north west corner of each page. By default, the header will not be printed. Call setLeftHeaderText(null) to suppress the printing of the header.
      Parameters:
      header - the text to print.
    • setRightHeaderText

      public void setRightHeaderText(String header)
      The header will be printed at north east corner of each page. By default, the header will not be printed. Call setRightHeaderText(null) to suppress the printing of the header.
      Parameters:
      header - the text to print.
    • showDateAndTime

      public void showDateAndTime(boolean b)
      Displays date and time on the printable page.
    • showPageNumbers

      public void showPageNumbers(boolean b)
      Displays page numbers on the printable page.
    • getDateAndTime

      public String getDateAndTime()
      Retrieves the date and time of the current locale.
    • getFormattedTableHeight

      public int getFormattedTableHeight(HFPageFormat pf)
      Retrieves the formatted imageable height used for clipping tables that does not allow splitting of any row along the bottom margin of the imageable area. Used only by tables (not for other components!).
    • renderComponent

      protected void renderComponent(Graphics2D g2d, int scaledPageH, int UP_SHIFT, double scale)
      This method renders the specified widget of type JComponent Override this method for any customized rendering purpose.
    • renderTableHeader

      protected void renderTableHeader(Graphics2D g2, int imgX, int imgY, int imgW, int imgH)
      This method renders the header portion of a table widget. Override this method for any customized rendering of the header.
    • renderDateAndTime

      protected void renderDateAndTime(Graphics2D g, int imgX, int imgY, int imgW, int imgH, int pOffSet)
      This method renders the date and time
    • renderPageNumbers

      protected void renderPageNumbers(Graphics g, int imgX, int imgY, int imgW, int imgH, int pOffSet)
      This method renders the page numbers.
    • renderPageHeader

      protected void renderPageHeader(Graphics g)
      Draw the header of each page.
      Parameters:
      g - the Graphics.
    • renderPageHeaderFooter

      protected void renderPageHeaderFooter(Graphics g)
      Draw the header of each page.
      Parameters:
      g - the Graphics.
    • paint

      public void paint(Graphics g)
      Overridden paint method that carries out the rendering of various graphics primitives including the component specified for printing.
      Overrides:
      paint in class JComponent
    • print

      public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException
      This method implements the Printable interface. Used exclusively for printing.
      Specified by:
      print in interface Printable
      Throws:
      PrinterException