I am working on a swings application I have a Jpanel, I am facing serious problem with printing this JPanel data with "card printer". This is working fine when i using paper color printer but when i am using card printer its printing nothing. I have tested the printer using some Images and it is printing fine when i print any Image directly but using my application having problem the card printer not receiving any data while the paper printer is printing fine. Any one faced this before or anyone please help me out. This is my code:
private void printCard(){
PrinterJob printjob = PrinterJob.getPrinterJob();
printjob.setJobName(" CUSTOMER 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 );
jLayeredPane2.paint(g2);
return Printable.PAGE_EXISTS;
}
});
if (printjob.printDialog() == false)
return;
try {
printjob.print();
}
catch (PrinterException ex) {
System.out.println("NO PAGE FOUND."+ex);
}
}