IllegalStateException on an observable list (original) (raw)

Tom Eugelink tbee at tbee.org
Sun Oct 21 12:37:19 PDT 2012


I have two observable lists; one containing appointments, the other containing selected appointments. If an appointment is removed from the first list, it also must be removed from the second. For this I setup a listener on the first list to handle this:

     // when appointments are removed, they can't be selected anymore
     appointments.addListener(new ListChangeListener<Agenda.Appointment>()
     {
         @Override
         public void onChanged(javafx.collections.ListChangeListener.Change<? extends Appointment> changes)
         {
             for (Appointment lAppointment : changes.getRemoved())
             {
                 selectedAppointments.remove(lAppointment);
             }
         }
     });

when constructing the control I get the following exception on the getRemoved() call.

Caused by: java.lang.IllegalStateException at com.sun.javafx.collections.NonIterableChange.checkState(NonIterableChange.java:101) at com.sun.javafx.collections.NonIterableChange$SimpleAddChange.getRemoved(NonIterableChange.java:158) at jfxtras.labs.scene.control.Agenda$1.onChanged(Agenda.java:108) at com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:134) at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:48) at com.sun.javafx.collections.ObservableListWrapper.callObservers(ObservableListWrapper.java:97) at com.sun.javafx.collections.ObservableListWrapper.addAll(ObservableListWrapper.java:171) at com.sun.javafx.collections.ObservableListWrapper.addAll(ObservableListWrapper.java:160) at com.sun.javafx.collections.ObservableListWrapper.addAll(ObservableListWrapper.java:309) at jfxtras.labs.scene.control.AgendaTrial1.start(AgendaTrial1.java:122) at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319) at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206) at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29) at com.sun.glass.ui.win.WinApplication$2$1.run(WinApplication.java:62) ... 1 more

Can someone explain why? And how to work around that?

Tom



More information about the openjfx-dev mailing list