我似乎无法在 <left>
上设置任何属性堆栈 Pane 。例如,我想将其宽度设置为 200。
<BorderPane fx:id="borderPane" fx:controller="main.Controller"
xmlns:fx="http://javafx.com/fxml" prefHeight="600.0" prefWidth="800.0">
<left prefWidth="200"> // This doesn't work
<ListView fx:id="listView"/>
</left>
<right>
<ImageView fx:id="staticImage"/>
</right>
</BorderPane>
我知道我可以通过编程来完成此操作:
StackPane left = new StackPane();
left.setPrefWidth(200);
borderPane.setLeft(left);
但出于我的项目的目的,我根本不能那样做。有替代方案吗?
最佳答案
您可以直接将发布的 Java 代码转换为 FXML:
<BorderPane fx:id="borderPane" fx:controller="main.Controller"
xmlns:fx="http://javafx.com/fxml" prefHeight="600.0" prefWidth="800.0">
<left>
<StackPane prefWidth="200" />
</left>
<right>
<ImageView fx:id="staticImage"/>
</right>
</BorderPane>
关于java - 我可以在 FXML 中设置 BorderPane 元素的宽度吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45590087/