PrinterJob job = PrinterJob.getPrinterJob();
MessageFormat[] header = new MessageFormat[3];
header[0] = new MessageFormat("");
header[1] = new MessageFormat("line 1");
header[2] = new MessageFormat("line 2");
MessageFormat[] footer = new MessageFormat[2];
footer[0] = new MessageFormat("footer 1");
footer[1] = new MessageFormat("footer 2");
job.setPrintable(new MyTablePrintable(tblmunim, PrintMode.FIT_WIDTH, header, footer));
if (job.printDialog())
try {
System.out.println("Calling PrintJob.print()");
job.print();
System.out.println("End PrintJob.print()");
}
catch (PrinterException pe) {
System.out.println("Error printing: " + pe);
}
Here is MyTablePrintable class
MyPrintable.java