简体   繁体   English

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

[英]How do I add a node between two other nodes in a HBox?

Consider the following code: 请考虑以下代码:

HBox hbox = new HBox();
Button button1 = new Button("A");
Button button2 = new Button("B");
hbox.getChildren().addAll(button1, button2);

If I wanted to add a node between the two current nodes, is there a way to do it without removing all the nodes first then re-adding them? 如果我想在两个当前节点之间添加一个节点,有没有办法在不删除所有节点的情况下再重新添加它们?

因为getChildren()返回一个ObservableList ,你是否应该能够使用add(int index, E element)在你想要的索引中添加元素?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM