简体   繁体   English

JavaFX场景构建器:具有与AnchorPane不同的根节点

[英]JavaFX scene builder: having a root node different from AnchorPane

JavaFX scene builder starts editing an AnchorPane. JavaFX场景构建器开始编辑AnchorPane。 JavaFX doesn't require the root Node to be an AnchorPane, there are cases in which another class is preferrable. JavaFX不要求根节点是AnchorPane,在某些情况下,另一个类是可取的。
Is there a way to change the rooot container in JavaFX Scene Builder? 有没有办法在JavaFX Scene Builder中更改rooot容器?

Choose menu Item: 选择菜单项:

File | 档案| New with Root Container Root容器的新功能

With b44 of the SceneBuilder, options available are Anchor Pane, Border Pane or Stack Pane 使用SceneBuilder的b44,可用的选项是Anchor Pane,Border Pane或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. 您还可以在文本编辑器中直接编辑fxml,将根窗格设置为例如Flow Pane,然后将编辑好的fxml加载到SceneBuilder中,SceneBuilder将识别它。

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: 要将另一个窗格设置为root而不是New with root container > ...下可用的三个altnerative(不直接编辑fxml),请执行以下操作:

  1. Insert pane you want as your new root as a child of whatever old root you have. 将您想要的新窗格作为您所拥有的旧root的子窗口插入。
  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 . 标记新根,然后从菜单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. 提示:使用菜单选项: Arrange > Wrap in > ...Arrange > Unwrap以插入或删除子项目周围的容器。

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

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