I have an a ChoiceBox that lists months values, when the user choose a value, it execute this lambda expression:
private TableView<IncomeFX> tableIncome;
private ChoiceBox<Month> choiceBoxIncomeMonths;
private ChangeListener<Month> setChoiceBoxIncomeMonthsBehaviour(){
ChangeListener<Month> months = (ObservableValue<? extends Month> observable, Month oldValue, Month newValue) -> {
incomesData.clear();
Year selectedYear = choiceBoxIncomeYears.getSelectionModel().getSelectedItem();
ObservableList<IncomeFX> temp = incomeManager.getIncomesOf(selectedYear, newValue);
incomesData.addAll(temp);
};
return months;
}
and how i add the listener:
choiceBoxIncomeMonths.getSelectionModel().selectedItemProperty().addListener(setChoiceBoxIncomeMonthsBehaviour());
when I click on the choicebox, i get:
Exception in thread "JavaFX Application Thread" java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:386)
at java.util.AbstractList$Itr.next(AbstractList.java:355)
at java.util.AbstractCollection.addAll(AbstractCollection.java:343)
at javafx.collections.ModifiableObservableListBase.addAll(ModifiableObservableListBase.java:99)
at lite.money.ui.MainUI.lambda$1(MainUI.java:160)
at lite.money.ui.MainUI$$Lambda$120/1680764266.changed(Unknown Source)
it indicate that the problem is in the line where I call: addAll(temp) how can i solve this ??? thanks