book.append number of pages

B

beowolf

I'm trying to print a "book" of two tables, each table has 3 pages.
Heres the code:

Printable jtp1= jTable1.getPrintable(JTable.PrintMode.FIT_WIDTH ,
new MessageFormat("jTable1"),null) ;
Printable jtp2= jTable2.getPrintable(JTable.PrintMode.FIT_WIDTH ,
new MessageFormat("jTable2"),null) ;

PrinterJob job = PrinterJob.getPrinterJob();
PageFormat portrait = job.defaultPage();
portrait.setOrientation(PageFormat.PORTRAIT);
Book bk = new Book();
bk.append(jtp1, portrait,3);
bk.append(jtp2, portrait,3);
job.setPageable(bk);
if (job.printDialog()) {
try {
job.print();
} catch (Exception exc) {
}
}

Unfortunately it only prints table1 (jtp1).
I've googled like a fool, but i've not found anything relevant to this
problem:
can anybody help me ?

Thank you
 
J

John B. Matthews

beowolf said:
I'm trying to print a "book" of two tables, each table has 3 pages.
Heres the code:
[...]
Unfortunately it only prints table1 (jtp1). I've googled like a fool,
but i've not found anything relevant to this problem: can anybody
help me ?

The table's getPrintable() will only image the visible part of the
component, anyway. For a multi-page table, consider one of print()
methods of JTable:

<http://java.sun.com/javase/6/docs/api/javax/swing/JTable.html>

Alternatively, see "Components Larger Than One Page":

<http://java.sun.com/developer/onlineTraining/Programming/JDCBook/advprint.html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top