Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Rufus Williams   on Jan 05 In Java Category.

  
Question Answered By: Adal Fischer   on Jan 05

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
*************
**********
******
****
**
*

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Print utilities Or get search suggestion and latest updates.


Tagged: