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?
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.