aspose file tools
The moose likes Swing / AWT / SWT and the fly likes Hiding JTable Columns Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Hiding JTable Columns" Watch "Hiding JTable Columns" New topic
Author

Hiding JTable Columns

Ajit Kumar
Ranch Hand

Joined: Jan 27, 2001
Posts: 81
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

Joined: May 06, 2000
Posts: 396
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

Joined: Jan 05, 2001
Posts: 174
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


If you love me, you will visit docs.opensimplatform.org
(FYI, Getting it tattooed on is a bit much.)
Skip Cole
Ranch Hand

Joined: Jan 05, 2001
Posts: 174
I finally found the answer!
column = table.getColumnModel().getColumn(col_numb_to_be_hidden);
table.removeColumn(column);
Skip
Sandhya Rprasad
Greenhorn

Joined: Mar 01, 2001
Posts: 24
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

Joined: Jul 16, 2001
Posts: 49
How do you hide more than one column and make it/them return when you want???
carlo serantonio
Greenhorn

Joined: Oct 16, 2004
Posts: 2
Hi.
I use following solution for alternate visibility of two column:



Thanks for suggest.
[ October 16, 2004: Message edited by: carlo serantonio ]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Hiding JTable Columns
 
Similar Threads
JTable
JTable
jtable
Jtable