I have a frame containing a JPanel with many components on it (like JLabel, JTextField etc.). But when I try to print the page like a print screen, it only draw part of the screen as if it has another page. How can I fit the components on the JPanel to be drawn into one page only?
Created May 4, 2012
Sandip Chitale The Print Screen simply copies the screen
or active frame only (if alt+Print Screen
was used) to the system clipboard in a native
format. Run any native program (paint.exe
on MS widnows), paste the clipboard image,
scale it and then print it.
if you want to print stuff programatically you will have to use the java.awt.PrintJob, get the page dimensions, print the component using the print(Graphics) method. Scale the image using java.awt.Graphics.drawImage(...) call or using Java2D apis. For swing make sure that you turn off the double buffering by calling RepaintManager's appropriate methods.