printing in java
Hi Java ppl.
I had posted a query regarding this topic earlier here but didn't get a reply. I have made a small word processor and the only thing missing is the print command and if anyone can tell me or refer me to some source where I can find something abt printing from a word processor made in java.
The main application is basically a textarea and currently the program prints a screenshot of my word processor not the contets of the textarea.
Anyone with some code on this would be very helpful.
Thanks.
Pradeep
[562 byte] By [
pra_sethi] at [2007-9-26 3:10:18]

Hi,since Java 1.2 the printing API is contained in the java.awt.print package. Key classes and interfaces are Printable, Pegable and PrinterJob.Regards,Martin
implement the Printable interface, all you have to do is create a
public int paint(Graphics g, PageFormat pf, int page)
{
// Do drawing
}
method, and draw your printing, i have some sample code if you need to see code.
Harold Smith III
www.javaxperience.com
hsmith@javaxperience.com
Instead of setting your entire word processor as Printable, just make your textArea printable.
Then your print method will print just the contents of the textarea.
check this site too -
http://manning.spindoczine.com/sbe/
Go to chapter 22 on printing, it contains lots of code examples.