All Implemented Interfaces:
This implementation spreads table rows naturally in sequence
across multiple pages, fitting as many rows as possible per page.
The distribution of columns, on the other hand, is controlled by a
printing mode parameter passed to the constructor. When
JTable.PrintMode.NORMAL is used, the implementation
handles columns in a similar manner to how it handles rows, spreading them
across multiple pages (in an order consistent with the table's
JTable.PrintMode.FIT_WIDTH is given, the implementation
scales the output smaller if necessary, to ensure that all columns fit on
the page. (Note that width and height are scaled equally, ensuring that the
aspect ratio remains the same).
The portion of table printed on each page is headed by the
appropriate section of the table's
Header and footer text can be added to the output by providing
MessageFormat instances to the constructor. The
printing code requests Strings from the formats by calling
format method with a single parameter:
Object array containing a single element of type
Integer, representing the current page number.
There are certain circumstances where this
cannot fit items appropriately, resulting in clipped output.
JTable.PrintMode.NORMALwhen a column is too wide to fit in the printable area. The center of the column is printed and no left and right borders are shown.
It is entirely valid for a developer to wrap this
inside another in order to create complex reports and documents. They may
even request that different pages be rendered into different sized
printable areas. The implementation was designed to handle this by
performing most of its calculations on the fly. However, providing different
sizes works best when
JTable.PrintMode.FIT_WIDTH is used, or
when only the printable width is changed between pages. This is because when
it is printing a set of rows in
JTable.PrintMode.NORMAL and the
implementation determines a need to distribute columns across pages,
it assumes that all of those rows will fit on each subsequent page needed
to fit the columns.
It is the responsibility of the developer to ensure that the table is not
modified in any way after this
Printable is created (invalid
modifications include changes in: size, renderers, or underlying data).
The behavior of this
Printable is undefined if the table is
changed at any time after creation.
public TablePrintable(JTable table, PrintMode printMode, MessageFormat headerFormat, MessageFormat footerFormat)
|Method from javax.swing.TablePrintable Summary:|
|Methods from java.lang.Object:|
|clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait|
|Method from javax.swing.TablePrintable Detail:|
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException