Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
考虑以下代码:
HBox hbox = new HBox(); Button button1 = new Button("A"); Button button2 = new Button("B"); hbox.getChildren().addAll(button1, button2);
如果我想在两个当前节点之间添加一个节点,有没有办法在不先删除所有节点然后重新添加它们的情况下做到这一点?
由于getChildren()返回 an ObservableList,您不应该能够使用add(int index, E element)将元素添加到您想要的索引处吗?
getChildren()
ObservableList
add(int index, E element)