[英]How do I add a node between two other nodes in a 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, E element)
在你想要的索引中添加元素?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.