- Forward


Printing
An Introduction with Examples in Java


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Overview
Back SMYC Forward
  • What Can Be Printed?
    • Objects that implement the Printable interface can be printed
  • Job Control:
    • Starts the process
The Printable Interface
Back SMYC Forward
  • The Printable Interface:
    • public int print(Graphics g, PageFormat format, int page)
  • Arguments:
    • A rendering engine
    • A format (e.g., dimensions, orientation)
    • A page number (which is 0-based)
Job Control
Back SMYC Forward
  • The Important Class:
    • PrinterJob
  • The Important Methods:
    • setPrintable()
    • printDialog()
    • print()
Controlling the Process
Back SMYC Forward
javaexamples/printing/PrinterController.java
 
A Wrapper for an Image
Back SMYC Forward
javaexamples/printing/PrintableImage.java
 
A Wrapper for a JComponent
Back SMYC Forward
javaexamples/printing/DelegatingPrintable.java
 
Printing Multiple Pages
Back SMYC Forward
  • Involves the Pageable interface
  • Also involves the Book class
There's Always More to Learn
Back -