我有错误:
Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: Index: 0
我以为是因为我必须使用Platform.runLater()
,但似乎错误并非来自于此。
这是我尝试纠正的功能Platform.runLater()
:
public void setListAirportForFilter(ListAirport listAirport){
this.myListAirport = listAirport;
departureCheckListView.setItems(myListAirport.getObservableDepartureAirtport());
arrivalCheckListView.setItems(myListAirport.getObservableArrivalAirport());
departureCheckListView.getCheckModel().getCheckedItems().addListener(new ListChangeListener<String>() {
@Override
public void onChanged(ListChangeListener.Change<? extends String> c) {
c.next();
if(c.wasAdded()) {
observableForbiddenDeparture.add(c.getAddedSubList().get(0));
System.out.println("Item Checked : " + c.getAddedSubList().get(0));
}
else if (c.wasRemoved()) {
observableForbiddenDeparture.remove(c.getAddedSubList().get(0));
System.out.println("Item Unchecked : " + c.getRemoved().get(0));
}
}
});
}
在第二种情况下触发的错误,已删除。