I have an object myObject which contains a property called myThing. The object myThing has an ArrayList and a property list which is connected to it. I have some JLabel myLabel which is bound to the list property.

To make this work, when the firePropertyChange is done, I have to make a clone of the list so that I pass a PropertyChangeEvent I have an old list and a new list to pass. This is very inefficient. Is there some way I should be doing this without the clone, that still allows me to bind properties?

Lists have been the bane of my existence lately.

有帮助吗?

解决方案

I think cloning the List is the way to go in your case. You know, cloning a list only clone its structure, not all the members it contains, so its not "that" inefficient.

其他提示

I think you should be take care of list clone. it is a shallow copy of this ArrayList instance, but the elements themselves are not copied. so, if you change copied ArrayList's element's property will be reflect to original ArrayList's element.

if you want your programs used ArrayList split, you should be rewrite ArrayList's clone method, use deeply copy.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top