opike
opike

Reputation: 7585

Java: Possible to replace TableModel in an existing JTable?

Is it possible to replace the entire TableModel in an existing JTable or do I have to recreate the JTable?

Upvotes: 7

Views: 10965

Answers (2)

user330315
user330315

Reputation:

You can set a new model using the JTable.setModel() method

Check the Javadocs for details

Upvotes: 15

Al morce
Al morce

Reputation: 51

When you change the model you are stuck with old column titles. getColumnName() only gets called on initialization.

Upvotes: 5

Related Questions