print Component - Java 2D Graphics

Java examples for 2D Graphics:Print

Description

print Component

Demo Code


import java.awt.*;
import javax.swing.*;
import java.awt.print.*;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main{
    public static void printComponent(Component c) throws PrinterException {
        PrinterJob job = PrinterJob.getPrinterJob();
        job.setPrintable(new ComponentPrinter(c));
        if (job.printDialog())
            job.print();/*from   w w  w.j  a  va2  s . c om*/
    }
}

Related Tutorials