Re: Bug? DefaultTableModel.setColumnIdentifiers(Object[]) results in null rowModel
- From: "John McGrath" <ng@xxxxxxxxxxxxx>
- Date: Thu, 26 May 2005 17:28:54 GMT
On 5/24/2005 at 7:01:56 PM, wasteheap@xxxxxxxxx wrote:
> This possible bug had me on a wild goose chase today. I am using JDK
> 1.5.0_02.
>
> public void DefaultTableModel.setColumnIdentifiers(Object[])
>
> When I call this method to change column identifiers, all my JTable row
> heights are effectively reset back to the default height. This doesn't
> seem like the proper result for what is supposed to be a "convenient"
> feature that is "not used by JTable."
I suspect you are using the column identifier for a different purpose than
it was intended, which is to attach objects to the columns of the table
model so that they can be used to identify the column and match them with
the corresponding TableColumns of the JTable. Generally, an identifier is
unique and does not change, so I would expect that it would be set when
the TableColumn is created and then not changed after that.
This seems to be what the author of DefaultTableModel has in mind. When
you set the ColumnIdentifiers, it initializes the columns. So if you set
them, it assumes that the entire structure of the table has changed, and
it fires a TableStructureChanged. The old columns are gone and new ones
are created.
> (Actually, it is used for more than just "tagging and location of
> columns" since it can be used to change column header values, but
> that is another story.)
To be a little more precise, JTable has a feature to automatically create
TableColumns from the TableModel. When it does this, it uses the column
identifiers for the column headers.
--
Regards,
John McGrath
.
- References:
- Prev by Date: Too much JMenu items in a JPopupMenu
- Next by Date: Re: applets won't appear
- Previous by thread: Bug? DefaultTableModel.setColumnIdentifiers(Object[]) results in null rowModel
- Next by thread: Displaying rotated ImageIcon on JScrollPane with menu bar
- Index(es):