• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How table column can be hidden from table model ?

 
Krishna Varma Adluru
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
How can I hide a table column from JTable without removing it from the underlying table model?
Thank You,
Regards,
Krishna Varma Adluru
 
Rajendar Goud
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can use removeColumn(column name)
and later on u can add the column using
addColumn(column name).
JTable table = ...
TableColumn deletedColumn = table.getColumn("Column Title");
table.removeColumn(deletedColumn);
It can later be added back into the table by addColumn(). This only affects what column is shown by the JTable; the model is unaffected
cheers,
Raj
 
Thomas Smets
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here you will find the basic exmaples Dave Marshall's site
Enjoy,
 
Krishna Varma Adluru
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thank You all guys for replying .. I will try them out and find how they work.
Thanks again,
Regards,
Krishna Varma Adluru
 
Ashik Uzzaman
Ranch Hand
Posts: 2373
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another way may be if you want to hide a column (not delete), you can set the width of the column to zero(0). So the column will remain but not be displayed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic