7

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

opike
  • 7,053
  • 14
  • 68
  • 95

2 Answers2

15

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

Check the Javadocs for details

5

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

summea
  • 7,390
  • 4
  • 32
  • 48
Al morce
  • 51
  • 1
  • 1
  • 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! – A. Harkous Jul 13 '18 at 08:29