0

hi everybody, cud neone here pls help me out in printing a page in Java. I have a page designed in swings which contains mainly labels and textareas. And i need to print this page in java with a click of a button. Could nebody arnd please help me out in this matter as it is very urgent and important. I will be really grateful to all the masters here.

<<snipped>>
Thanks and kind regards,
Rahul Gupta.

2
Contributors
3
Replies
5
Views
9 Years
Discussion Span
Last Post by lucky1981_iway
0
PrintService[] services3 = PrintServiceLookup.lookupPrintServices([B]null[/B], [B]null[/B]);
AttributeSet aset3 = [B]new[/B] HashAttributeSet();
aset3.add([B]new[/B] PrinterName("my printer name", [B]null[/B]));
aset3.add(MediaTray.BOTTOM);
services3 = PrintServiceLookup.lookupPrintServices([B]null[/B], aset3);
PrinterJob pjob = PrinterJob.getPrinterJob();

try this . it will work

0

thanks for the prompt reply. but how can I implement this with my JFrame page.???

PrintService[] services3 = PrintServiceLookup.lookupPrintServices([B]null[/B], [B]null[/B]);
AttributeSet aset3 = [B]new[/B] HashAttributeSet();
aset3.add([B]new[/B] PrinterName("my printer name", [B]null[/B]));
aset3.add(MediaTray.BOTTOM);
services3 = PrintServiceLookup.lookupPrintServices([B]null[/B], aset3);
PrinterJob pjob = PrinterJob.getPrinterJob();

try this . it will work

0

You want to take printout of which thing ...?
You can add print job listener to your printjob and then you can implement your own set of actions.
Or in actionPerformed of button event you can create a printjob and add it for printing.

something like this

services3.createPrintJob();
.
.
.
pjob.print();
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.