Is it possible to replace the entire TableModel in an existing JTable or do I have to recreate the JTable?
Java: Possible to replace TableModel in an existing JTable?
Asked Answered
You can set a new model using the JTable.setModel()
method
Check the Javadocs for details
Damn - I was using the inline javadoc in the eclipse editor and I missed it, but I went back and checked and it's there. –
Amphoteric
Very helpful in the case of a JXTreeTable as well, where you might have to use
setTreeTableModel()
. –
Lethargic When you change the model you are stuck with old column titles. getColumnName()
only gets called on initialization.
so it is not possible to change the column names as well? In my case, I want to make a data viewer table, it gets initialized without data and filled once a different thread provides the model. But, as you said, column names are not appearing! –
Plenty
© 2022 - 2024 — McMap. All rights reserved.