PDA

View Full Version : Printing Java GLAnimCanvas



Mat
06-28-2002, 03:57 AM
Hi,

I m developping an GUI interface using Java and OpenGL (GL4 libraries)...

I have an OPenGL GLAnimCanvas that inherits from awt.Canvas. I try to print it but I only print a blank page and I do not know why.. here is my printing code in my GLAnimCanvas class..

************************************************** **********************
public int print(Graphics g, PageFormat pf, int pageIndex) {

if (pageIndex >= 1) {
return Printable.NO_SUCH_PAGE;
}

Graphics2D g2 = (Graphics2D) g;
System.out.println(pf.getImageableX()+" "+pf.getImageableY());
g2.translate(pf.getImageableX(), pf.getImageableY());
paint(g2);
return Printable.PAGE_EXISTS;
}

/************************************************** ****************************/
// The requestPrint() method is called when an evnt is detected on a Jbutton

public void RequestPrint() {

PrinterJob printerJob = PrinterJob.getPrinterJob();
printerJob.setPrintable(this);
boolean doPrint = printerJob.printDialog();
if (doPrint) {
try {
printerJob.print();
} catch (PrinterException exception) {
System.err.println("Printing error: " + exception);
}
}
}

/************************************************** *******/

Thanks a lot for your help..
Mat

rael II
06-28-2002, 07:39 AM
Are you passing the GLAnimCanvas' g directly, or it's parent container's?

Mat
07-01-2002, 12:04 AM
Hi,

I pass directly the GLAnimCanvas.. This two methods are in the class of the GLAnimCanvas..

Mat