JavaFX scene builder: having a root node different from AnchorPane


Question

JavaFX scene builder starts editing an AnchorPane. JavaFX doesn't require the root Node to be an AnchorPane, there are cases in which another class is preferrable.
Is there a way to change the rooot container in JavaFX Scene Builder?

1
5
7/2/2012 4:49:37 PM

Accepted Answer

Choose menu Item:

File | New with Root Container

With b44 of the SceneBuilder, options available are Anchor Pane, Border Pane or Stack Pane

You can also directly edit the fxml in a text editor to set the root pane to for instance a Flow Pane, then load the edited fxml into the SceneBuilder and the SceneBuilder will recognize it.

4
7/2/2012 5:23:59 PM

To set another pane as root rather than the three altneratives available under New with root container > ... (without editing the fxml directly), do the following:

  1. Insert pane you want as your new root as a child of whatever old root you have.
  2. Place whatever else you have as direct descendants of the old root into the new root.
  3. Mark the new root and select from menu Edit > Trim document to selection.

Voila!

Tip: Use the menu selections: Arrange > Wrap in > ... and Arrange > Unwrap to insert or remove containers around child items.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon