• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sizing a JFrame during printAll()

 
Timothy Hoyle
Greenhorn
Posts: 18
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Once again, I have been pulling my hair out searching the web for the solution to this, all to no avail.

So I ask youguys, how do I resize my JFrame during printing so that it prints the whole JFrame? I am asking because I have a JFrame that when printed using graphics2d and a printerJob(), prints only the top left corner of the JFrame, while I want it to print the whole thing without cutting it off.

If someone could at least point me in the right direction I would be very grateful. Thanks in advance.

Below should be all of the relevant code.

 
Stanislav Lapitsky
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just after the g2d.translate(pf.getImageableX(), pf.getImageableY());
add
g2d.scale(scale, scale);

where the scale should be min of
pf.getImageableWidth()/frame.getWidth()
and
pf.getImageableHeight()/frame.getHeight()

Hope this helps,

Stas
 
Timothy Hoyle
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stanislav,

Works great, thanks for the help.

Regards,

Tim Hoyle
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!