• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating a copy of an existing JTable that does not have source code.

 
Vidya Reddy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am working on a java swing based application. We used a third party API for JTable for showing some data in a table format and also for printing function. As of now print button is printing the whole table being shown in the application. Our new requirement of printing is �Users don�t want to print all the columns being shown in the application and they wanted to have print of columns whatever they would like to see�.

The above requirement can be fulfilled if I can have a copy of the existing table. Unfortunately we don�t have the source code of the table being shown in the application as we are using 3rd party libraries. Had the source code been there I could have implemented cloneable interface or proto type pattern.

Can some body help me how can I create a copy of the existing table? Basically the high level approach I thought of is create a new object of the table class and copy the properties/attributes of the existing table to the new table object. But I don�t know what attributes should be copied so that I can have the copy of the original table and how to construct (code) this new table.

I would be very grateful if some one could help me with this.

Thanks & Regards
Vidya
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the TableColumnModel. Its main purpose is to allow you to filter out (and rearrange) columns of the TableModel.
 
Vidya Reddy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeff Albertson

Thank you very much for the pointer. However the following issue is there if I touch the columns of the existing table object.

It is changing the view (removing/changing the location of columns) in the application if I modify columns of the original table object for printing sake.

Due to this problem, I wanted to create all together a new table object for printing purpose. Then it will not affect the view of the application.

Do you have any idea how I can create a copy of the table being shown in the application?

Thanks & Regards
Vidya
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you considered:
1. briefly filtering out the columns you do not want to print
2. printing
3. restoring the original TableColumnModel
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!