Hi,
First, I hope this is the right area. I did search and I found most of the questions regarding JPanel printing are in this section. I also found that none of the ones that seemed to be similar to my problem had any responses. I hope I have better luck.
My deliverable is a program that prints ID
cards on a special card printer. It should also show a scaled up preview of the card for proofing before sending the job to the printer. I've decided that to make the process as simple as possible I would have two JPanels, one for the preview and one for printing. That's not my issue.
My issue is this: I was having a lot of problems with scaling the print job and figuring out how to adjust the paper size to the card's size, so I created a simpler project that is very basic. It shows the JPanel (actual size) and has a print button to print it. The problem is that when I do print it, the first page only has a narrow vertical rectangle on it in the color of the JPanel background. Subsequent pages print correctly.
Also, it prints way to many pages. It should only print one, but since I'm a little confused on how to translate the pixel size of the JPanel to the 1/72" scale used to define the paper it doesn't seem to work right.
This is my first
Java program that requires printing so I'm still pretty new at it. Please keep that in mind when you look at the source for my
test project below and try not to laugh.
Here's the source minus package declaration and imports: