Customizing JTable.print() method to print table data with varying row heights

77 views Asked by At

GOAL: Print a table with each row having varying row heights to GUI and to a physical printer using custom renderers.

I am able to print the JTable data to a table within my Java Swing GUI by extending the TableCellRenderer using a customized renderer to change the row height for each row depending on the height needed for each row.

int height = stringValue.length * 22;
if(height > table.getRowHeight(row)) {
    table.setRowHeight(row, height);
}

This works for the GUI display and outputs perfectly to my screen.

However, when I want to physically print a paper copy of the entire table, I am unable to correctly print the new row heights using the jtable.print() method. Instead, the data is being cut off because only a single row height is used for all rows. i.e. it ignores my new inputs (from the looks of it).

0

There are 0 answers