Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/356.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在HBox中的两个其他节点之间添加节点?_Java_Javafx_Hbox - Fatal编程技术网

Java 如何在HBox中的两个其他节点之间添加节点?

Java 如何在HBox中的两个其他节点之间添加节点?,java,javafx,hbox,Java,Javafx,Hbox,考虑以下代码: HBox hbox = new HBox(); Button button1 = new Button("A"); Button button2 = new Button("B"); hbox.getChildren().addAll(button1, button2); 如果我想在两个当前节点之间添加一个节点,有没有一种方法可以不先删除所有节点,然后再重新添加它们 既然getChildren()返回了一个ObservableList,您难道不能使用add(int-index,

考虑以下代码:

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元素)
将元素添加到您想要的索引中吗?

谢谢!我不确定从Java文档的什么地方开始获取我的答案,但您的答案让我一目了然。我现在应该能够回答类似的问题,非常感谢。