Article View: borland.public.jbuilder.java.swing
Article #1735Re: Default columns (A, B, C) in JTable
From: John McGrath [TeamB]
Date: Tue, 26 Aug 2003 05:02
Date: Tue, 26 Aug 2003 05:02
22 lines
1926 bytes
1926 bytes
On 8/25/2003 at 11:24:40 AM, Ed Wood wrote: > I have a JTable using the DefaultTableColumnModel and a TableModel > which extends AbstractTableModel. I have added 3 columns to my > JTable, but those columns appear after 3 columns named A, B and C. > > Why are those default columns there, and how do I remove them? The default behavior for a JTable is to automatically add columns to the TableColumnModel by querying the TableModel for the number of columns, the column names and the column classes. This is controlled by the "AutoCreateColumnsFromModel" property, so you could turn it off by calling setAutoCreateColumnsFromModel(false) on the JTable. Another way of dealing with it is to implement the getColumnName() and getColumnClass() methods in the TableModel and then let the JTable create and populate the TableColumnModel for you. -- Regards, John McGrath [TeamB]
Technical Details
Message-ID:
<3f4ae9ee@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!newsfeed.news2me.com!newsfeed.media.kyoto-u.ac.jp!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f4a2a38$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,b623673dc5551dfe X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2003-08-25 22:09:45 PST From: "John McGrath [TeamB]" <ng-b@jpmcgrath.net> Subject: Re: Default columns (A, B, C) in JTable Newsgroups: borland.public.jbuilder.java.swing References: <3f4a2a38$1@newsgroups.borland.com> User-Agent: XanaNews/1.15.6.1 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 NNTP-Posting-Host: 141.158.52.223 Message-ID: <3f4ae9ee@newsgroups.borland.com> Date: 25 Aug 2003 22:02:38 -0700 X-Trace: newsgroups.borland.com 1061874158 141.158.52.223 (25 Aug 2003 22:02:38 -0700) Lines: 22 X-Authenticated-User: jpmcgrath Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!newsfeed.news2me.com!newsfeed.media.kyoto-u.ac.jp!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail