1

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?

1 Answers1

3

since getChildren() returns an ObservableList, shouldnt you be able to use the add(int index, E element) to add the element at your desired index?

user2573153
  • 254
  • 2
  • 14
  • Thanks! I wasn't exactly sure where to start on the Java Docs to obtain my answer but your answer walked me right through it. I should be able to answer similar questions now, much appreciated. – user1390463 Jan 14 '14 at 02:44