Forums Register Login

JTable column headings - how to change AFTER JTable instantiation

+Pie Number of slices to send: Send
Is there a way to change the column headings for a JTable that has already been instantiated? I have spent hours going over the API's for TableModel, TableColumnModel, etc., and just can't find a Class or method that will let me do it!
Any ideas?
Thanks
+Pie Number of slices to send: Send
The table model hast a method getColumnName() which returns the names of the columns whenever the JTable questions them. It will call this method especially after a TableStructureChanges event occured, which would be fired by the TableModel.
Thus, to change the column names (headers):
1. change the columns in the implementation of the
table model (you're free on that)
2. fireTableStructureChanged (that might not be the exact name, but it's something like that) in the table model.
3. the rest should happen automatically!
Chantal
We can fix it! We just need some baling wire, some WD-40, a bit of duct tape and this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 799 times.
Similar Threads
JTable
Updating a JTable
JTable
Wants Header of a JTable to be static.
JTable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:36:49.