Setting the Nth Element of a Layout

VAADIN’s AbstractLayout, the parent of Horizontal and VerticalLayouts, contains methods to add components to the back and in front of existing ones, but not in the middle of them. It should be pretty obvious how to perform this task, but it is not. Once a component is moved to another layout it is removed from the original, so an iteration will not work as the list of components changes in size in each iteration.

I have posted code for this at:

Is there a better way to achieve it?

Thank you.