我有一个BorderPane作为根元素,HBox在它的顶部。在HBox中,我有5 AnchorPanes,其中4.充当间隔。这是经过简化的FXML:
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="710.0" prefWidth="1190.0" stylesheets="@style.css" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<top>
<HBox prefHeight="70.0" BorderPane.alignment="CENTER">
<children>
<AnchorPane prefHeight="70.0" prefWidth="200.0">
...
</AnchorPane>
<AnchorPane prefHeight="70.0" prefWidth="200.0">
...
</AnchorPane>
<AnchorPane prefHeight="70.0" prefWidth="200.0">
...
</AnchorPane>
<AnchorPane id="empty" minWidth="0.0" prefHeight="70.0" prefWidth="0.0" HBox.hgrow="ALWAYS" />
<AnchorPane prefHeight="70.0">
...
</AnchorPane>
</children>
</HBox>
</top>
</BorderPane>我的问题是,当我调整窗口的大小时,empty窗格正在增长,但它不会缩小到初始宽度以下(应用程序启动时的大小)。
显示正在(或没有)发生的事情的视频:https://jumpshare.com/v/0QriIiITUlSRgLMy4ev5
这是预期的行为,还是JavaFX中的一个bug?
发布于 2016-06-03 11:29:15
在FXML中,在BorderPane定义中替换:
minWidth="-Infinity"使用
minWidth="0".问题是您的HBox没有缩小,因为BorderPane本身不再缩小了。
最小宽度为0将确保BorderPane将缩小,因此HBox也将被调整大小。
我已经尝试过您的FXML,通过这个小小的修改,布局看起来是正确的。
https://stackoverflow.com/questions/37609861
复制相似问题