I want to print the entire swing screen (with content) using Java print API. How should I go about it? I tried calling print()/printAll() method on JFrame, but it's creating a problem in component alignment on the paper. Like only half JTable is getting printed etc. Do I need to override paintComponent(Graphics g) before printing the each component or is there any better way of doing it?
Thanks for the code, but still things are not working for me. My scenario is like this: I have a swing screen with one JTable in the middle of the screen and a logo image below the JTable resulting in 2 pages (print wise). I am new to swing/printing, so cold you please help me with the multiple page thing? I am not getting how to use Doc or Book as you suggested. I am passing my entire JFrame as component to print(). Also as per my understanding graphics.translate() should rearrange the table according to page coordinates, but even it's not happening that way. Let me know if you want me to send a screen shot of the page am trying to print.