• Post Reply Bookmark Topic Watch Topic
  • New Topic

printing data from JEditor Pane

 
Richa Goyal
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a program in which the data is shown in JEditor Pane. I have used HTMl tags to get the desired format. Now i want to print it. how should i proceed? :roll:
 
Kriti Garg
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

there are classes like
java.awt.print.PrinterException;
java.awt.print.PrinterJob;
available,make some button below ur editor pane panel

like printbtn and where htmlPage is ur Editor pane

printBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {


PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(htmlPage);
if (printJob.printDialog()) {
try {
printJob.print();
}
catch (PrinterException pe) {
logger.error("print()Error in Printing" + pe);

}
}
}
});
 
It's a beautiful day in this neighborhood - Fred Rogers. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!