• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Hiding JTable Columns

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I finally found the answer!
column = table.getColumnModel().getColumn(col_numb_to_be_hidden);
table.removeColumn(column);
Skip
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you hide more than one column and make it/them return when you want???
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic