gpt4 book ai didi

javafx-2 - 为什么我的 JavaFX HBox 中的 child 不会长大(SceneBuilder)?

转载 作者:行者123 更新时间:2023-12-03 21:21:15 24 4
gpt4 key购买 nike

JavaFX docs for HBox说:

If an hbox is resized larger than its preferred width, by default it will keep children to their preferred widths, leaving the extra space unused. If an application wishes to have one or more children be allocated that extra space it may optionally set an hgrow constraint on the child. See "Optional Layout Constraints" for details.



在附图中,为什么按钮没有填充水平宽度?

enter image description here

HBox.setHgrow(field, Priority.ALWAYS)不一样吗?文档引用的代码。

最佳答案

选择您在屏幕截图中所做的按钮,并在右侧布局 Pane 中的那些大小框中将最大宽度设置为:

MAX_VALUE

这将阻止按钮的最大大小绑定(bind)到按钮的首选大小。

请参阅 Oracle 的 Tips for Sizing and Aligning Nodes

UI controls also provide default minimum and maximum sizes that are based on the typical usage of the control. For example, the maximum size of a Button object defaults to its preferred size because you don't usually want buttons to grow arbitrarily large.



……

To enable all of the buttons to be resized to the width of the VBox pane, the maximum width of each button is set to the Double.MAX_VALUE constant, which enables a control to grow without limit. An alternative to using the maximum value constant is to set the maximum width to a specific value, such as 80.0.

关于javafx-2 - 为什么我的 JavaFX HBox 中的 child 不会长大(SceneBuilder)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16242398/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com