-1

I'm looking for a pattern to notify my JTable that the Data which are handled in the TableModel have changed. The Idea is that I got a global singleton TreeSet managing the Data. I receive randomly updates on the TreeSet.If any changes are made to the TreeSet the TableModelshould update itself by gathering the new information from the TreeSet.

Observer? Events + Listener? anything else?

Thank you for your help!

ps: A way to update the Model is already implemented and is NOT part of the Question.

JonasP
  • 51
  • 1
  • 6

3 Answers3

2

You basically answered your own question, observer, event + listeners. A change from the usual: have you tried?

MarioDS
  • 12,895
  • 15
  • 65
  • 121
1

Question was a little confusing, but it sounds like you should be using AbstractTableModel.fireTableDataChanged(), as described here.

Rob I
  • 5,627
  • 2
  • 21
  • 28
1

You could take a look at Listening for Data Changes

Consider the method fireTableStructureChanged. You can see an example in CustomEditorTableModel

And you can see another in SortingaColumninaJTableComponent

Paul Vargas
  • 41,222
  • 15
  • 102
  • 148
  • sorry for not making it clear but I already can Update the model that was not the question. (as you see in the last line of my question) – JonasP May 10 '12 at 07:41