Re: Default columns (A, B, C) in JTable


2003-08-26 01:02:38 PM
jbuilder10
On 8/25/2003 at 11:24:40 AM, Ed Wood wrote:
Quote
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]