Hy ,

I have a jTable , for printing it i`m using jTable.print(JTable.PrintMode.FIT_WIDTH).
I have no problem with that.
What i want to do is this (the table extends on 3 pages):
On the first page the title should be "Bla bla bla" , and o the last page under the table it should print "Total : blablabla , blabla ...". I tried to use header and footer but it prints it o every page which is not what i want.

Can anybody help me ?

Thanks

1) that not possible, you have to add one JLabel on the TOP and 2nd on BOTTOM,

2) not possible change Font and another methods,

MessageFormat header = new MessageFormat(" Whatever");
MessageFormat footer = new MessageFormat(" Page {0,number,integer}            Whatever");
     try {
         PrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
         set.add(OrientationRequested.LANDSCAPE);
         myTable.print(JTable.PrintMode.FIT_WIDTH, header, footer, false, set, false);
         JOptionPane.showMessageDialog(null, "\n" + "JTable was Successfully "
                + "\n" + "Printed on your Default Printer");
     } catch (java.awt.print.PrinterException e) {
         JOptionPane.showMessageDialog(null, "\n" + "Error from Printer Job "
                + "\n" + e);   
     }

Thank you for replying ,

I thought about adding jLabels at top and bottom , but i don`t know how to print it because i`d need to print a jFrame or something.

If i do jLabel.print , jTable.print , jLabel.print , it would print out 5 pages (1 label , 3 table , 1 label)

Can i make it continuous?

1) JTable printable returns Graphics, and there you can add two Graphics from TOP & BOTTOM JLables, both are generated only for printing

2) follows describtion by link I posted you

3) accepting default mess implemented by JTable Printable

4) don't print Header & Footer

5) I'd suggesting use implemented print interface for JTable, otherwise you have to create Custom Graphics for each page separatelly,

6) there are free and non-free API, but I never needed these, nor interesting about that somehow with deepest, sorry ..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.