没有左右儿童的JavaFX Borderpane [英] JavaFX Borderpane without left and right children

查看:505
本文介绍了没有左右儿童的JavaFX Borderpane的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法让Borderpane将节点设置在中心,以便在左右插槽中没有子节点时占据窗口的整个宽度。我使用Scene Builder来创建FXML文件,当前,当我调整应用程序窗口的大小时,中心节点的左侧,右侧和底部都有大量的空白区域。有没有办法摆脱它们?

I wondering if there's a way to make Borderpane have the node set at the center to take up the full width of the window if there are no children in the left and right slots. I used Scene Builder to create the FXML file and currently, when I resize the window of the application, there are massive white spaces to the left, right, and bottom of the node in the center. Is there a way to get rid of them?

这是目前的样子:

推荐答案

如果您有节点 BorderPane 为中心它将被调整大小以填充中心的剩余空间。

If you have a Node centered in a BorderPane it will be resized to fill the remaining space in the center.


顶部和底部儿童将被调整为他们的首选高度
并扩展边框窗格的宽度。左右子元素
将调整为其首选宽度,并在顶部和底部节点之间延长
的长度。 中心节点将调整大小
以填充中间的可用空间。
任何位置可能是
null。

The top and bottom children will be resized to their preferred heights and extend the width of the border pane. The left and right children will be resized to their preferred widths and extend the length between the top and bottom nodes. And the center node will be resized to fill the available space in the middle. Any of the positions may be null.

但它使用实际节点的布局范围进行调整。

But it gets resized using the layout bounds of the actual Node.

如果您查看 maxWidth 节点的<> maxHeight 方法:

If you take a look on the documentation of maxWidth and maxHeight methods of Node:


返回节点的最大值宽度(高度)用于布局
计算。如果节点可调整大小,则其父节点不应将其宽度调整为大于此值的
。值Double.MAX_VALUE
表示父节点可以将节点的宽度扩展到其首选的
之外,没有限制。

Returns the node's maximum width(height) for use in layout calculations. If the node is resizable, its parent should not resize its width any larger than this value. A value of Double.MAX_VALUE indicates the parent may expand the node's width beyond its preferred without limits.

所以,如果没有看到你的实际代码,我想问题是你已经设置了你放在 BorderPane 中心的控件的最大大小,因此它确实没有超出该限制的重新调整大小。正如文档所述,您应该将其设置为 Double.MAX_VALUE ,以使 BorderPane 能够调整大小以填充整个剩下的空间。

So, without seeing your actual code I guess the problem is that you have set the maximal size of your control that you have placed into the center of the BorderPane, therefore it does not get resized beyond that limit. As the documentation states you should set it to Double.MAX_VALUE to make the BorderPane able to resize it to fill the whole space left.

这篇关于没有左右儿童的JavaFX Borderpane的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆