Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX scene builder: having a root node different from AnchorPane

Tags:

java

javafx

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?

like image 419
AgostinoX Avatar asked Jul 02 '12 16:07

AgostinoX


2 Answers

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.

like image 86
jewelsea Avatar answered Nov 15 '22 09:11

jewelsea


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.

like image 39
Terje Dahl Avatar answered Nov 15 '22 08:11

Terje Dahl