The error appears sometimes when I try to do a setLeft in a BorderPane. The problem comes from the following line:
bpDetail.setLeft(selected ? ivSelected : null);
I want to draw an image when something is selected to the left of the borderPane, but sometimes the program throws the following error:
Caused by: java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at java.util.ArrayList.rangeCheck(ArrayList.java:657)
at java.util.ArrayList.get(ArrayList.java:433)
at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89)
at com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:306)
at javafx.scene.Parent$2.onProposedChange(Parent.java:423)
at com.sun.javafx.collections.VetoableListDecorator.remove(VetoableListDecorator.java:329)
at com.sun.javafx.collections.VetoableListDecorator.remove(VetoableListDecorator.java:221)
at javafx.scene.layout.BorderPane$BorderPositionProperty.invalidated(BorderPane.java:673)
at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)
at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
at javafx.scene.layout.BorderPane.setLeft(BorderPane.java:314)
at main.Selectable.showSelected(Selectable.java:594)
at main.Selectable.initialize(Selectable.java:300)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
... 14 more
Does anyone understand why this happens sometimes?
Thanks in advance!