JavaFX使用SceneBuilder将节点添加到ScrollPane [英] JavaFX Add Node to ScrollPane with SceneBuilder

查看:92
本文介绍了JavaFX使用SceneBuilder将节点添加到ScrollPane的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题

在代码中,如果我这样做,它会完美地工作:

  TilePane tilePane = new TilePane();ScrollPane scrollPane =新的ScrollPane(tilePane); 

我的意思是,每次 TilePane 有更多可以显示的项目时, scroll 就会垂直水平出现代码>,而无需添加任何额外代码或设置 TilePane 的最小或首选大小.

使用SceneBuilder

我不想使用纯代码,而希望使用SceneBuilder获得与上面相同的结果,但是每次我尝试这样做时,都会发生:

我必须将首选大小设置为 TilePane .为什么会这样?而且它没有按预期工作.我希望它按照问题的第一行中的描述自动运行.需要一个很好的描述...

解决方案

请参见 prefWidth prefHeight USE_COMPUTED_SIZE .这些是 TilePane 的默认值,但是当您将 TilePane 放到 ScrollPane 中时,SceneBuilder似乎将它们设置为默认数值./p>

您可以通过单击 prefWidth prefHeight 文本字段的文本字段旁边的下拉框直接选择这些值.

The problem

In code it works perfectly if i do it like:

TilePane tilePane = new TilePane();
ScrollPane scrollPane = new ScrollPane(tilePane);

I mean that every time the TilePane has more items that can be shown then a scroll appears vertically or horizontally without adding any extra code or setting minimum or preferred size of TilePane.

Using SceneBuilder

Instead of using pure code i want to have the same result as the above using SceneBuilder but every time i am trying to do it something like this: happens

I have to set the preffered size to the TilePane.Why thought? And it doesn't work as expected.I want it to automatically work as described in the first lines of the question.A good description is needed...

解决方案

See the prefWidth and prefHeight to USE_COMPUTED_SIZE. These are the default values for a TilePane, but SceneBuilder seems to set them to default numeric values when you drop the TilePane into a ScrollPane.

You can select these values directly by clicking on the drop-down boxes next to the text field for the prefWidth and prefHeight text fields.

这篇关于JavaFX使用SceneBuilder将节点添加到ScrollPane的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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