i have custom collection implements listmodel
. when collection changes, need notify jlist
. typically you'd firelistdatachanged
, not method implemented listmodel
.
how should go modifying code automatically update jlist
?
jlist here:
this.selectedinterfacesjlist.setmodel(new tufininterfacecollection());
collection here:
public class tufininterfacecollection extends abstractcollection<tufininterface> implements listmodel<string> { arraylist<tufininterface> list=new arraylist(); private final arraylist listeners=new arraylist(); @override public boolean remove(object o) { return list.remove(o); //to change body of generated methods, choose tools | templates. } @override public boolean add(tufininterface e) { return list.add(e); //to change body of generated methods, choose tools | templates. } public tufininterface get(int i){ return list.get(i); } @override public iterator<tufininterface> iterator() { return list.iterator(); } @override public int size() { return list.size(); } @override public int getsize() { return size(); } @override public string getelementat(int i) { return get(i).tostring(); } @override public void addlistdatalistener(listdatalistener ll) { this.listeners.add(ll); } @override public void removelistdatalistener(listdatalistener ll) { this.listeners.remove(ll); } }
Comments
Post a Comment