I have a Composite whose main widget has two children, thus:
public MyComposite() {
child1 = new FlowPanel();
child1.getElement().setId("child1");
child2 = new FlowPanel();
child2.getElement().setId("child2");
panel = new FlowPanel();
panel.add(child1);
panel.add(child2);
initWidget(panel);
}
Some time after construction of MyComposite, I want to swap child1 out, replacing it with another widget, new-child1.
I could perhaps remove child1 by calling panel.remove(child1), and then add my new widget by calling panel.add(new-child1); but this would cause child2 to be rendered first, wouldn't it?
So, how can I replace child1 with new-child1 without changing the order of panel's children?