sarahrobin wrote on Apr 12th, 2007, 10:03pm:does anyone know how to program a print option
i'd like to have it to when you click a button it prints.
any ideas
thanks.:)
There's some old code in the ALPHA discourse BB that still works -- I just used it in v0124:
http://processing.org/discourse/yabb/YaBB.cgi?num=1085540961
void printscreendavid()
{
try {
java.awt.print.PrinterJob pjob = java.awt.print.PrinterJob.getPrinterJob();
pjob.setJobName("FingerprintMazeMap -- You are there.");
pjob.setCopies(1);
pjob.setPrintable(new java.awt.print.Printable() {
public int print(Graphics pg, java.awt.print.PageFormat pf, int pageNum) {
if (pageNum > 0)
return java.awt.print.Printable.NO_SUCH_PAGE; // end of job
superPaint(pg);
return java.awt.print.Printable.PAGE_EXISTS;
}
});
// calling printDialog forces an OS print dialog -- we don't like os dialogs
// if (pjob.printDialog() == false)
//return;
pjob.print();
} catch (java.awt.print.PrinterException pe) {
}
}
void superPaint(Graphics g) {
super.paint(g);
}