How to notify ListModel that ArrayList have changed

363 views Asked by At

I would like to notify ListModel that a certain ArrayList have been modified.

My ArrayList is automatically updated after I create every person by:

new Person(...);

It is achieved as I add every person to ArrayList at the end of Person constructor. I would like to ListModel listen to any changes in that ArrayList. The ArrayList is part of a HashMap<Class, ArrayList> where all instances of every class are stored.

How to notify ListModel that the ArrayList have been changed?

Notice: I don't mean: how to make ListModel notify the Jlist.

1

There are 1 answers

2
user489041 On

Use an ObservableList instead of ArrayList and register a ObservableListListener on your ListModel

or for simplicty sake, use a Property Change Listener