Package edu.cnu.mdi.util
Class PrintUtils
java.lang.Object
edu.cnu.mdi.util.PrintUtils
- All Implemented Interfaces:
Printable
Prints Swing components either directly or from an EDT-created snapshot.
-
Field Summary
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS -
Constructor Summary
ConstructorsConstructorDescriptionPrintUtils(Component componentToBePrinted) Convenience constructor with default settings: fitToPage=true, centerOnPage=true, allowUpscale=falsePrintUtils(Component componentToBePrinted, boolean fitToPage, boolean centerOnPage, boolean allowUpscale) Full constructor with behavior knobs: -
Method Summary
Modifier and TypeMethodDescriptionvoidprint()Show print dialog and print if user confirms.intprint(Graphics g, PageFormat pf, int pageIndex) static voidConvenience method to print a component with default settings:static voidCapture a component on the EDT and print the resulting image.
-
Constructor Details
-
PrintUtils
Convenience constructor with default settings: fitToPage=true, centerOnPage=true, allowUpscale=false- Parameters:
componentToBePrinted- component to print
-
PrintUtils
public PrintUtils(Component componentToBePrinted, boolean fitToPage, boolean centerOnPage, boolean allowUpscale) Full constructor with behavior knobs:- Parameters:
componentToBePrinted- component to printfitToPage- if true, scale to fit imageable areacenterOnPage- if true, center within imageable area (after scaling)allowUpscale- if false, scale will never exceed 1.0 (no enlarging)
-
-
Method Details
-
printComponent
Convenience method to print a component with default settings:- Parameters:
c- the component to print (must have non-zero size)
-
print
public void print()Show print dialog and print if user confirms. -
print
- Specified by:
printin interfacePrintable- Throws:
PrinterException
-
printComponentAsImage
Capture a component on the EDT and print the resulting image.- Parameters:
c- component to capture and print
-