Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Print utilities

  Asked By: Rufus    Date: Jan 05    Category: Java    Views: 986
  

I just wanted to know about the print utilities of java in detail.Are
there any books/links for that...

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Adal Fischer     Answered 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
*************
**********
******
****
**
*

 
Answer #2    Answered By: Devlan Jones     Answered On: Jan 05

how to run this program? why in void main method is empty ?

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




Tagged: