Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Meenachi Suppiah   on May 09 In Java Category.

  
Question Answered By: Ginger Snyder   on May 09

using printable,
import java.awt.*;
import java.awt.print.*;

public class PrintableComponent implements Printable {
Component c;
public PrintableComponent(Component c) { this.c = c; }

public void print() throws PrinterException {
PrinterJob job = PrinterJob.getPrinterJob();
PageFormat format = job.pageDialog(job.defaultPage());
job.setPrintable(this, format);
if (job.printDialog())
job.print();
}

public int print(Graphics g, PageFormat format, int pagenum) {
if (pagenum > 0)
return Printable.NO_SUCH_PAGE;

Graphics2D g2 = (Graphics2D) g;

g2.transl
c.paint(g2);

return Printable.PAGE_EXISTS;
}
}

Share: 

 

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

 


Tagged: