Forums Register Login

Printing invicible JTable with Column removed - JTable.PrintMode.FIT_WIDTH problem

+Pie Number of slices to send: Send
My JTable is a table with some columns including a checkbox column. When the user clicks on the print button, the program will create an invisible copy of the visible table, then add a rowsorter to exclude all the rows with a checkbox that is set to false. then remove the checkbox column from the table. For the table to print I manually change the size of the table (else the content will not print).
That is how I set up the table, I hope it made sense.

But it is when I set the table to print with JTable.PrintMode.FIT_WIDTH thats not working as it should. The table is not printed across the whole page, like it still believes that the removed column is still there, resulting in that the rigthmost column will be cut, and not all data will be printed. I don't have this problem when printing JTable.PrintMode.NORMAL.
I hope my explanation made sense.

I have tried a long time to fix this but without result.
I'd be gratefull if someone could help me.


Here is the code.

edit: I have removed the code till someone who knows tells me it is okay (see the two posts below).
+Pie Number of slices to send: Send
Is it legal to post copyright code on a public forum?
+Pie Number of slices to send: Send
 

Darryl Burke wrote:Is it legal to post copyright code on a public forum?



If it is not, then I am sorry, and will remove the code, until someone gives me permission. Though I personally think I did do as the copyright stated, but it is up to the moderators to decide. I will remove the code until someone tells me it is okay. Just to let others know who read this later, it was code of Sun's JTable Printing example that was modified. I did keep the copyrighted text, so I never claimed it to be my own.

I'm sorry if I did something I should'nt have done.
+Pie Number of slices to send: Send
I was able to solve the problem by myself, and will share it here. I have done a new program, and nothing is taken from Sun's example. The content of the method is a modified version of java2s.com's Set column width based on cell renderer, if I remember right. As far as I know this is not copyrighted code, atleast I coud'nt find anything about it. If anyone have a different opinion, then please tell me, and I will remove the code.

Heres the code:

Alas, poor Yorick, he knew this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2563 times.
Similar Threads
Printing invisible JTable containing JTables - problem
Printing jtable
JTable printing . . .
JTable
columnwidth in JTable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 13:11:32.