• Post Reply Bookmark Topic Watch Topic
  • New Topic

Printing: JTextArea or JPanel, whichever will work! Help!  RSS feed

Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ok, I originally posted a question about problems with printing in the wrong forum, and the thread is here.

I'm using Marty Hall's print routine to print any component. I added some extra code, which I found elsewhere to scale the component so it would fit on the page. It prints, but I have the truncation issues mentioned above.

Since I was having difficulty, I decided to try something else. I switched to using Marty Hall's code with no changes, and created a JTextArea which I fill in with the text I want to send, then use that JTextArea object as what gets sent to PrintUtilities.printComponent.

However, while the printer does spit out a page, it's completely blank! I've used the default Constructor for the JTextArea, and numerous appends to fill in the information. But I just get a blank page. I tried displaying the JTextArea, and it's filled in with the proper text.

What am I forgetting to do or doing wrong?

For those not familiar with it, see the link to my other thread. The lines staring with:

// scale to fill the page

and ending with:

g2d.scale(scale, scale);

are not part of Marty's code. I had those in so the JPanel would fit on the paper, but when I tested with JTextArea, I used only Marty's original code.
[ February 04, 2005: Message edited by: Joe Vahabzadeh ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!