This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing JTable

 
Chad Risch
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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 ]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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!
 
Manish Hatwalne
Ranch Hand
Posts: 2591
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic