posted 21 years ago
U have to write the code that u want to print inside the print method. Say for u have some squares drawing in the Paint method. Same code u have to write in the Print method.
void Paint()
{
Graphics2D g2D=(Graphics2D)g;
Rectangle rect = newRectangle(10,10,20,20);
g2D.draw(rect);
}
public int print(Graphics g,PageFormat pageFormat,int pageIndex)throws PrinterException
{
if(pageIndex>0)
return NO_SUCH_PAGE;
Graphics2D g2D=(Graphics2D)g;
Rectangle rect = newRectangle(10,10,20,20);
g2D.draw(rect);
return PAGE_EXISTS;
}