|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdsto.dfc.swing.controls.PrintUtility
public class PrintUtility
A simple utility class that lets you very simply print an arbitrary component. Just pass the component to the PrintUtility.printComponent. The component you want to print doesn't need a print method and doesn't have to implement any interface or do anything special at all. If you are going to be printing many times, it is marginally more efficient to first do the following: PrintUtility printHelper = new PrintUtilities (theComponent); then later do printHelper.print (). But this is a very tiny difference, so in most cases just do the simpler PrintUtilities.printComponent (componentToBePrinted). Taken from 7/99 Marty Hall, http://www.apl.jhu.edu/~hall/java/ May be freely used or adapted.
Field Summary |
---|
Fields inherited from interface java.awt.print.Printable |
---|
NO_SUCH_PAGE, PAGE_EXISTS |
Constructor Summary | |
---|---|
PrintUtility(Component componentToBePrinted,
PageFormat pageFormat)
Initializes variables. |
Method Summary | |
---|---|
static void |
disableDoubleBuffering(Component c)
The speed and quality of printing suffers dramatically if any of the containers have double buffering turned on. |
static void |
enableDoubleBuffering(Component c)
Re-enables double buffering globally. |
void |
print()
Opens up a print dialog and prints if the user clicks ok. |
int |
print(Graphics g,
PageFormat myPageFormat,
int pageIndex)
Draws the component to be printed. |
static void |
printComponent(Component c,
PageFormat pageFormat)
Calls the print method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PrintUtility(Component componentToBePrinted, PageFormat pageFormat)
componentToBePrinted
- The component that is to be printed.pageFormat
- Used to obtain the current PageLayout settings stored in
the page format.Method Detail |
---|
public static void printComponent(Component c, PageFormat pageFormat)
c
- The component to be printed.pageFormat
- Used to obtain the current PageLayout settings stored in
the page format.public void print()
public int print(Graphics g, PageFormat myPageFormat, int pageIndex)
print
in interface Printable
g
- The Graphics object.myPageFormat
- The current page format.pageIndex
- The current page index.
public static void disableDoubleBuffering(Component c)
enableDoubleBuffering(java.awt.Component)
public static void enableDoubleBuffering(Component c)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |