Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hiding JTable Columns  RSS feed

 
Ajit Kumar
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How do i hide a specific column in a JTable object.?
Setting setPreferredSize to 0 is not working.
Any suggestions?
Thanks
 
deekasha gunwant
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ajit,
to set the columnwidth to zero u need to set all three
setMaximumWidth(0);
setPreferredWidth(0);
setMinimumWidth(0);
setPreferredWidth(0) does not work alone.
regards
Deekasha
 
Skip Cole
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This is not working for me. I still get a phantom column, about 1 character wide.
I have tried and tried to make it go away, but it persists.

Any ideas?
Skip
 
Skip Cole
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I finally found the answer!
column = table.getColumnModel().getColumn(col_numb_to_be_hidden);
table.removeColumn(column);
Skip
 
Sandhya Rprasad
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this !!
It worked for me !!
Good luck .. Sandhya
TableColumn column1 = null;
column1 = JTable1.getColumnModel().getColumn(no. of the col you want to hide);
column1.setMaxWidth(0);
column1.setMinWidth(0);
column1.setWidth(0);
column1.setPreferredWidth(0);
 
keiyia jackson
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you hide more than one column and make it/them return when you want???
 
carlo serantonio
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I use following solution for alternate visibility of two column:



Thanks for suggest.
[ October 16, 2004: Message edited by: carlo serantonio ]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!