Posted 19 April 2012 - 07:10 AM
Mine looks pretty much like yours at this point.
I did manage to figure something out, though. I used the GroupLayout's linkSize() method to link the horizontal size of all the JLabels, and as a result, the 'n' on the end of 'John' printed perfectly. However, the space between DOB and SSN was still negative width. This leads me to believe it's a font metrics issue. Perhaps between rendering in screen space and rendering on device space, something changes. I'd like to know what exactly is causing it though.
As a matter of interest, perhaps you can answer this for me (since I have a limited understanding of how Java's printing API works.) When I create the JPanel to print, but I do not add it to the JFrame on the screen, when I go to print it, nothing prints. It's just blank. However, when I do add it to the screen, and the components are realized as Swing constructs the JFrame, it does print.
If I can avoid having to display it in this way in order to get it to print, I'd like to do so. Is there a way to have Swing realize the components, but not in screen space, but rather in device space only? Perhaps then the font metrics issue wouldn't be a problem.
I'm just guessing here. Let me know if I'm way off base.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid