-
Hide a column in JTable?
How do I hide a particular column? I would still like to maintain all the
data for that column there, so that I can retrieve the selected data easily,
but I would like to have some columns that are not relevant to the user to
be hidden.
--
Best Regards,
Wing Hoe
---------------------------------------------------------------
ICQ: 2213281
Email: winghoe@hotmail.com
www: http://pwp.maxis.net.my/winghoe
Job Seeking Status : Active
Availability : May 2001 (after degree course finish)
---------------------------------------------------------------
-
Re: Hide a column in JTable?
Set its width to zero. Or if you are never going to display it, don't even
include it in your table. Just have your table model provide only the
displayable data.
PC2
Lim Wing Hoe <winghoe@hotmail.com> wrote in message
news:3a359ef6@news.devx.com...
> How do I hide a particular column? I would still like to maintain all the
> data for that column there, so that I can retrieve the selected data
easily,
> but I would like to have some columns that are not relevant to the user to
> be hidden.
>
-
Re: Hide a column in JTable?
There are two or three methods of doing it.
1.Use removeColumnModel on the JTable. This wont remove the actual data from
the underlying tablemodel but only form the View the JTable. DIsadvantege
of this is that if you want to restore the column it becomes messy coding.
2.You can have an array of booleans saying whether each column is to be displayed
or not. Then you should override the getValueAt and setValueAt,etc functions
of the tablemodel so that the correct column number is used - for the column
number passed by the JTable will be with respect to the columns displayed
while the tablemodel's data Vector(or array) will be having more values.
Search in codeguru.com for a full sample of this.
I personally feel that method two is better.
"Paul Clapham" <pclapham@core-mark.com> wrote:
>Set its width to zero. Or if you are never going to display it, don't even
>include it in your table. Just have your table model provide only the
>displayable data.
>
>PC2
>
>Lim Wing Hoe <winghoe@hotmail.com> wrote in message
>news:3a359ef6@news.devx.com...
>> How do I hide a particular column? I would still like to maintain all
the
>> data for that column there, so that I can retrieve the selected data
>easily,
>> but I would like to have some columns that are not relevant to the user
to
>> be hidden.
>>
>
>
>
-
Re: Hide a column in JTable?
Ramkumar,
Thanks for replying. I've been analyzing the same theory that you mentioned,
method 2. I will try to do this.
Oh yeah, I've just sent a reply to the message "How to listen to JTable
events?". I've written a piece of code near the end of the message in
regards to how I'm gonna retrieve the data. Do you think it will work?
--
Best Regards,
Wing Hoe
---------------------------------------------------------------
ICQ: 2213281
Email: winghoe@hotmail.com
www: http://pwp.maxis.net.my/winghoe
Job Seeking Status : Active
Availability : May 2001 (after degree course finish)
---------------------------------------------------------------
"Ramkumar" <ramkuma@usa.net> wrote in message
news:3a3b2f95$1@news.devx.com...
>
> There are two or three methods of doing it.
> 1.Use removeColumnModel on the JTable. This wont remove the actual data
from
> the underlying tablemodel but only form the View the JTable. DIsadvantege
> of this is that if you want to restore the column it becomes messy coding.
>
> 2.You can have an array of booleans saying whether each column is to be
displayed
> or not. Then you should override the getValueAt and setValueAt,etc
functions
> of the tablemodel so that the correct column number is used - for the
column
> number passed by the JTable will be with respect to the columns displayed
> while the tablemodel's data Vector(or array) will be having more values.
> Search in codeguru.com for a full sample of this.
>
> I personally feel that method two is better.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks