I am trying to print a JPanel called comp .It contains a tabel and some labels.When ever I
print the comp the table goes beyond the page's width. I really don't understand why this is
happening . Need a solution to this problem
Here is the print method I am using:
private void printCard(){
PrinterJob printjob = PrinterJob.getPrinterJob();
printjob.setJobName(" personal card ");
printjob.setPrintable (new Printable() {
public int print(Graphics pg, PageFormat pf, int pageNum){
pf.setOrientation(PageFormat.LANDSCAPE);
if (pageNum > 0){
return Printable.NO_SUCH_PAGE;
}
Graphics2D g2 = (Graphics2D) pg;
g2.translate(pf.getImageableX(), pf.getImageableY());
g2.translate( 0f, 0f );
comp.paint(g2);
return Printable.PAGE_EXISTS;
}
});
if (printjob.printDialog() == false)
return;
try {
printjob.print();
}
catch (PrinterException ex) {
System.out.println("NO PAGE FOUND."+ex);
}
}
Thanks in advance.