Printing Java GLAnimCanvas

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

Are you passing the GLAnimCanvas’ g directly, or it’s parent container’s?

Hi,

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

Mat