• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Printing JTable

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I'm trying to print out a JTable but I'm having some problems. Currently, my table is spanning too far width wise and so columns are being printed on seperate pages when I want them to all be on the same page. It is a fairly wide table, but it all fits on my screen, so I would like to shrink the table to whatever size necessary to get it to fit on the page. I'm only concerned with the width fitting to the page. I don't mind having multiple pages due to having many rows. Can anyone one guide me in the right direction? If possibly, I'd appreciate examples, but if that isn't possibly, I'll take whatever anyone can offer. Thanks in advance.
Note: auto resizing is already in place. I just want to shrink the table somehow when it gets sent from the screen to the printed page.
[ March 12, 2004: Message edited by: irncty99 ]
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"irncty99" -

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it here.

Thanks! and welcome to the JavaRanch!
 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this -
double pageWidth = pageFormat.getImageableWidth();
double tableWidth = (double) this.getColumnModel().getTotalColumnWidth();
double scale = 1;
if (tableWidth >= pageWidth) {
scale = pageWidth / tableWidth;
}
hould work. Refer to
http://java.sun.com/developer/onlineTraining/Programming/JDCBook/advprint.html
for more help.
- Manish
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic