Java tutorial
import java.awt.Graphics; import java.awt.print.PageFormat; import java.awt.print.Printable; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import javax.swing.JComponent; public class BasicPrint extends JComponent implements Printable { public int print(Graphics g, PageFormat pf, int pageIndex) { double x = 0; double y = 0; double w = pf.getWidth(); double h = pf.getHeight(); return Printable.NO_SUCH_PAGE; } public static void main(String[] args) { PrinterJob pjob = PrinterJob.getPrinterJob(); PageFormat pf = pjob.defaultPage(); pjob.setPrintable(new BasicPrint(), pf); try { pjob.print(); } catch (PrinterException e) { } } }