• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Sizing a JFrame during printAll()

 
Greenhorn
Posts: 18
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stanislav,

Works great, thanks for the help.

Regards,

Tim Hoyle
 
Yeah, but does being a ninja come with a dental plan? And what about this tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic