title: Same observed list in several views
body: <p>I have two views (JPanel) that uses the same domain object.  My domain object contains a <code>ObservableList</code>.  </p>
  
  <p>The ObservableList is a LinkedList</p>
  
  <pre><code>private ObservableList&lt;MyObject&gt; listMyObject = ObservableCollections.
      observableList(Collections.synchronizedList(new LinkedList&lt;MyObject&gt;()));
  </code></pre>
  
  <p>In my two views I to do some calculation each time an element is added to the list</p>
  
  <pre><code>protected class MyListDataListener implements ObservableListListener {
     public void listElementsAdded(ObservableList list, int index, int length) {
     MyObject obj = (MyObject)list.get(index);
     Poin2D location = obj.getObjLocation();
     location.setLocation(location.x + (time / getWidth()), location.y);
     obj.setObjLocation(location);
  }
  </code></pre>
  
  <p>The problem I have is that as both views use the same list each time one element is added to the list the location is updated two times the object that is moving in the view finish its animation two times faster.  I would like it to be updated only one time for each element added.</p>
  
  <pre><code>public class MyFrame extends JFrame {
  public MyFrame() {
  View view1 = new View(domainObject.getMyDataList());
  View view2 = new View(domainObject.getMyDataList());
  }
  }
  
  public class View extends JPanel {
  private ObservableList&lt;MyObject&gt; listMyObject;
  private ObservableList&lt;MyObject&gt; otherList = ObservableCollections.
      observableList(Collections.synchronizedList(new LinkedList&lt;MyObject&gt;()));
  
  public View(ObservableList&lt;MyObject&gt; listMyObject) {
  this.listMyObject = listMyObject;
  listMyObject.addListListener(new MyListDataListener());
  }
  
  protected class MyListDataListener implements ObservableListListener {
     public void listElementsAdded(ObservableList list, int index, int length) {
  otherList.add((MyObject)list.get(index));
  for(MyObject obj : otherList) {
  Poin2D location = obj.getObjLocation();
     location.setLocation(location.x + (time / getWidth()), location.y);
     obj.setObjLocation(location);
  }
  }
  </code></pre>
  
  <p>If i don't create view2, everything is working fine.  With view2 created each time an element is added each view iteratate the list and change the location of my object two times instead of one time.
  Thank you for help.</p>