【发布时间】:2014-02-01 23:37:02
【问题描述】:
考虑以下代码:
HBox hbox = new HBox();
Button button1 = new Button("A");
Button button2 = new Button("B");
hbox.getChildren().addAll(button1, button2);
如果我想在两个当前节点之间添加一个节点,有没有办法在不先删除所有节点然后重新添加它们的情况下做到这一点?
【问题讨论】:
考虑以下代码:
HBox hbox = new HBox();
Button button1 = new Button("A");
Button button2 = new Button("B");
hbox.getChildren().addAll(button1, button2);
如果我想在两个当前节点之间添加一个节点,有没有办法在不先删除所有节点然后重新添加它们的情况下做到这一点?
【问题讨论】:
既然getChildren() 返回一个ObservableList,你不应该可以使用add(int index, E element) 在你想要的索引处添加元素吗?
【讨论】: