J
JavaRookie
When I attempt to print the Graphics contents of a swing component, the print
dialog shows to print 9999 pages. But it should contain only 1 page.
Can anyone tell me why is that happening? and how to fix it?
Thx a lot!!
PrinterJob job = PrinterJob.getPrinterJob();
job.setCopies(1);
job.setPrintable(new Printable() {
public int print(Graphics g, PageFormat pf, int pageIndex) {
aSwingComponent.printAll(g);
return Printable.PAGE_EXISTS;
}
});
// Then when I show the print dialog, it shows 9999 pages to print!!
if (job.printDialog()) {
try {
job.print();
}
catch (Exception e) { }
}
dialog shows to print 9999 pages. But it should contain only 1 page.
Can anyone tell me why is that happening? and how to fix it?
Thx a lot!!
PrinterJob job = PrinterJob.getPrinterJob();
job.setCopies(1);
job.setPrintable(new Printable() {
public int print(Graphics g, PageFormat pf, int pageIndex) {
aSwingComponent.printAll(g);
return Printable.PAGE_EXISTS;
}
});
// Then when I show the print dialog, it shows 9999 pages to print!!
if (job.printDialog()) {
try {
job.print();
}
catch (Exception e) { }
}