简体   繁体   English

JavaFX Borderpane,不带有左右子元素

[英]JavaFX Borderpane without left and right children

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. 我想知道是否有一种方法可以使Borderpane在中心位置设置节点以占据窗口的整个宽度(如果左右插槽中没有子代)。 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. 我使用Scene Builder创建FXML文件,当前,当我调整应用程序窗口的大小时,中间节点的左,右和底部有巨大的空白。 Is there a way to get rid of them? 有办法摆脱它们吗?

Here is what it currently looks like: 这是当前的样子:

在此处输入图片说明

If you have a Node centered in a BorderPane it will be resized to fill the remaining space in the center. 如果您的某个NodeBorderPane中居中,它将被调整大小以填充中心的剩余空间。

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 . 但是它会使用实际Node的布局范围进行调整大小。

If you take a look on the documentation of maxWidth and maxHeight methods of Node : 如果您查看一下NodemaxWidthmaxHeight方法的文档:

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. Double.MAX_VALUE的值指示父节点可以将节点的宽度扩展到其首选范围之外,而没有限制。

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. 因此,在没有看到实际代码的情况下,我想问题是您已将控件的最大尺寸设置为BorderPane的中心,因此它的大小不会超出该限制。 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. 如文档所述,您应将其设置为Double.MAX_VALUE以使BorderPane能够调整其大小以填充剩余的整个空间。

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

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