I am developing a program in netbeans forms. I've got to a point where I will click a jButton to print the content of either JFrame or JPanel.
I am using Netbeans forms to develop the project, Please could anyone help me sove this issue?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
I am developing a program in netbeans forms. I've got to a point where I will click a jButton to print the content of either JFrame or JPanel.
I am using Netbeans forms to develop the project, Please could anyone help me sove this issue?
If you have not read the following I recommend it:
Lesson: Printing (The Java™ Tutorials > 2D Graphics)
If you have read it, I recommend posting what you have tried as an SSCCE with a specific question about your code.
I am writing a software that allows the user to print a receipt. The receipt has been designed in a JInternal Frame enclosed in JPanel. I want to be able to print the receipt. The code i wrote when a click on the print button, it just triggers the frame without showing print dialog. Since I am new in Java and netbeans I am finding it very difficult to accomplish the project which I must submit on Monday. I used netbeans forms to design the project and this is my Print code. I know something is wrong somewhere along the code but I cannot figure it out. I want somebody to help me accomplish this task.
private void jButton11ActionPerformed(java.awt.event.ActionEven t evt) {
PageFormat pf = new PageFormat();
Graphics Graphic=jInternalFrame2.getGraphics();
Graphics2D g2d = (Graphics2D)Graphic.create();
g2d.translate(pf.getImageableX(), pf.getImageableY());
print(g2d.create());
}
Thank you
Threads merged and moved.
Please do not start duplicate threads on the same topic.
Please post your code using code or highlight tags as explained near the top of this topic.
What has changed since your first post, if anything? Did you make any progress after following copeg's suggestion?