try this:
public class PrintInvoice extends JFrame implements Printable
{
public PrintInvoice(int TN,String type,int hours,int minutes)
{
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(this);
try {printJob.print();} catch(Exception ex){ex.printStackTrace();}
}
public static void main(String[]args)
{
}
public int print(Graphics g, PageFormat pf, int pi) throws PrinterException {
if (pi >= 1) {
return Printable.NO_SUCH_PAGE;
}
drawShapes((Graphics2D) g);
return Printable.PAGE_EXISTS;
}
public void drawShapes(Graphics2D g2){
}
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
drawShapes(g2);}
}
this will print the things that was painted in the draw shapes method
i hope it helps
yours
*************
**********
******
****
**
*