wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Printing invicible JTable with Column removed - JTable.PrintMode.FIT_WIDTH problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Printing invicible JTable with Column removed - JTable.PrintMode.FIT_WIDTH problem" Watch "Printing invicible JTable with Column removed - JTable.PrintMode.FIT_WIDTH problem" New topic
Author

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

Alexander Walker
Ranch Hand

Joined: Jun 04, 2010
Posts: 34
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).
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

Is it legal to post copyright code on a public forum?


luck, db
There are no new questions, but there may be new answers.
Alexander Walker
Ranch Hand

Joined: Jun 04, 2010
Posts: 34
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.
Alexander Walker
Ranch Hand

Joined: Jun 04, 2010
Posts: 34
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:

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Printing invicible JTable with Column removed - JTable.PrintMode.FIT_WIDTH problem