IllegalStateException on an observable list

Mark Fortner phidias51 at gmail.com
Sun Oct 21 16:13:33 PDT 2012


I guess part of the problem is the semantics of the word "Change".  Perhaps
"ChangeSet" or some kind of collective noun would make it more obvious that
you have more than one item that you need to iterate through.

Cheers,

Mark




On Sun, Oct 21, 2012 at 1:12 PM, Tom Eugelink <tbee at tbee.org> wrote:

> How blond can one be, overlooked that. Thanks.
>
> Tom
>
>
> On 2012-10-21 22:07, Martin Klähn wrote:
>
>> Hi,
>>
>> it seems you've missed to iterate through the collected changes in that
>> Change. if you wrap your for-loop in while(c.next()) it'll work. you can
>> then optionally check if the change was caused by appointments being
>> removed from the list or by something else. See
>> http://docs.oracle.com/javafx/**2/api/javafx/collections/**
>> ListChangeListener.Change.html<http://docs.oracle.com/javafx/2/api/javafx/collections/ListChangeListener.Change.html>for reference.
>>
>> Martin
>>
>>
>>
>> On Sun, Oct 21, 2012 at 9:37 PM, Tom Eugelink <tbee at tbee.org <mailto:
>> tbee at tbee.org>> wrote:
>>
>>     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