Action handler does the work of the printing test.
Graphics pg = null; // refers to current page
System.out.println("Doing print");
pjob = getToolkit().getPrintJob(this,
"Printing Test", (Properties)null);
if (pjob == null) // User cancelled??
return;
Dimension pDim = pjob.getPageDimension();
int pRes = pjob.getPageResolution();
System.out.println("Page size " + pDim + "; Res " + pRes);
// Print up to NPAGES
for (int pgNum=0; pgNum<nPages; pgNum++) {
System.out.println("Starting page # " + pgNum);
pg = pjob.getGraphics();
if (pg == null) // ??
return;
// setColor needed on Solaris (a bug!?)
pg.setColor(Color.black);
pg.setFont(new Font("Helvetica", Font.PLAIN, 48));
pg.drawString("Hello World", 200, 200);
pg.drawString("Page " + pgNum, 300, 300);
System.out.println("Disposing of page " + pgNum);
pg.dispose(); // flush page
System.out.println("Disposed of page " + pgNum);
}
pjob.end(); // total end of print job.
pjob = null; // avoid redundant calls to pjob.end()