Source:
public List<E> subList(int fromIndex, int toIndex) { final ObservableArrayList subList = new ObservableArrayList(list.subList(fromIndex, toIndex)); subList.onChanged(new ListChangeListener() { @Override public void listChanged(ListChangeEvent evt) { final List<ListChangeEvent.Change<E>> changes = Assert.requireNonNull(evt, "evt").getChanges(); final Iterator<ListChangeEvent.Change<E>> iterator = changes.iterator(); while (iterator.hasNext()) { final ListChangeEvent.Change<E> change = iterator.next(); if (change.isAdded() && evt.getSource() != null) { int fromIndex = list.indexOf(evt.getSource().get(change.getFrom() - 1)); list.addAll(fromIndex + 1, evt.getSource().subList(change.getFrom(), change.getTo())); } else if (change.isReplaced() && evt.getSource() != null && !change.getRemovedElements().isEmpty()) { if (list.contains(change.getRemovedElements().get(0))) { int index = list.indexOf(change.getRemovedElements().get(0)); list.set(index, (E) evt.getSource().get(change.getFrom())); } } else if (!change.getRemovedElements().isEmpty()) { list.removeAll(change.getRemovedElements()); } } } }); onChanged(new ListChangeListener<E>() { @Override public void listChanged(ListChangeEvent<? extends E> evt) { final List<? extends ListChangeEvent.Change<? extends E>> changes = Assert.requireNonNull(evt, "evt").getChanges(); final Iterator<? extends ListChangeEvent.Change<? extends E>> iterator = changes.iterator(); while (iterator.hasNext()) { final ListChangeEvent.Change<? extends E> change = iterator.next(); if (change.isAdded() && evt.getSource() != null) { } else if (change.isReplaced() && evt.getSource() != null && !change.getRemovedElements().isEmpty()) { if (subList.contains(change.getRemovedElements().get(0))) { int index = subList.indexOf(change.getRemovedElements().get(0)); subList.set(index, (E) evt.getSource().get(change.getFrom())); } } else if (!change.getRemovedElements().isEmpty()) { subList.removeAll(change.getRemovedElements()); } } } }); return subList; }

Target:
public List<E> subList(int fromIndex, int toIndex) { final ObservableArrayList subList = new ObservableArrayList(list.subList(fromIndex, toIndex)); subList.onChanged(new ListChangeListener() { @Override public void listChanged(ListChangeEvent evt) { final List<ListChangeEvent.Change<E>> changes = Assert.requireNonNull(evt, "evt").getChanges(); for (final ListChangeEvent.Change<E> change : changes) { if (change.isAdded()) { final int fromIndex = list.indexOf(evt.getSource().get(change.getFrom() - 1)) + 1; list.addAll(fromIndex, subList.subList(change.getFrom(), change.getTo())); } else if (change.isReplaced()) { if (list.contains(change.getRemovedElements().get(0))) { final int index = list.indexOf(change.getRemovedElements().get(0)); list.set(index, (E) subList.get(change.getFrom())); } } else if (change.isRemoved()) { list.removeAll(change.getRemovedElements()); } } } }); onChanged(new ListChangeListener<E>() { @Override public void listChanged(ListChangeEvent<? extends E> evt) { final List<? extends ListChangeEvent.Change<? extends E>> changes = Assert.requireNonNull(evt, "evt").getChanges(); for (final ListChangeEvent.Change<? extends E> change : changes) { if (change.isAdded()) { } else if (change.isReplaced()) { if (subList.contains(change.getRemovedElements().get(0))) { final int index = subList.indexOf(change.getRemovedElements().get(0)); subList.set(index, (E) list.get(change.getFrom())); } } else if (change.isRemoved()) { subList.removeAll(change.getRemovedElements()); } } } }); return subList; }