I am having a problem with this piece of code:
for(Node n : start.getChildren()) {
singlewidth = ((CustomController) n).getWidth();
totalwidth += singlewidth;
if(swidth < totalwidth) {
//start.getChildren().remove(b);
start.getChildren().add(mb);
start.getChildren().remove(n);
}
if(swidth > totalwidth){
start.getChildren().add(n);
start.getChildren().remove(mb);
}
}
The trick here is that I want to go through all the elements in the HBox, and try to adapt them by width. But on the line, where I re-add the Node n, NetBeans throws the ConcurrentModificationException. Can somebody help me please?