I am having issues understanding which interface I need to listen to changes in a listModel. I thought it was ListDataListener, but I can't understand the methods in it. There are 3 methods in it and this one seems to be the one I want but I can't understand the description:
contentsChanged(ListDataEvent e)
Sent when the contents of the list has changed in a way that's too complex to characterize with the previous methods.
What does it mean by "too complex"? And by "characterize with the previous methods"? Well, what does the whole thing mean? Is this the interface I want?
Yes, that's the right listener.
The statement means that this method is the more general one, that will cover every possible change to the list content. The other ones (
intervalAdded
andintervalRemoved
) should be used when those specific events occur.In my practice you will always use the most general one (even with table listeners).. I guess it was supposed to be used to optimize (especially with big lists).
A tutorial on this listener can be found here.