Printing Components on a JPanel
I have application that displays JLabels with Images on a JPanel. The JPanel layout is set to NULL so I can arrange the JLabels on the panel using the mouse. This all works. However, after arranging the JLabels on the JPanel, I would like to printout the arrangement.
Can someone tell me how to do this? When I tried sample code I've seen on this forum, it seems the panel and its components are print over and over again until the end of the page. So it looks like overlays every 1/2 inch.
Here is the code i've tried for the print method:
public int print(Graphics g, PageFormat pf, int pi) throws PrinterException
{
if (pi > 0) {
return(NO_SUCH_PAGE);
} else {
Graphics2D g2d = (Graphics2D)g;
g2d.translate(pf.getImageableX(), pf.getImageableY());
paintAll(g2d);
return(PAGE_EXISTS);
}
}
Thanks in advance for the help.
augie

