ChoiceBox 有 50 个选项,如何限制下拉列表的高度。 Java 场景构建器

ChoiceBox has a 50 options how can I limit the height of drop down list. Java Scenebuilder

我的程序演示的图像,我希望它一次只显示 10 个左右的项目以供选择。如有任何帮助,我们将不胜感激!

image of my program issue

不能限制ChoiceBox下拉列表的高度。

documentation of ChoiceBox 明确指出:

The ChoiceBox is used for presenting the user with a relatively small set of predefined choices from which they may choose.

50 个可能的选择不属于“相对较小的集合”类别。

您可以使用 ComboBox 而不是 ChoiceBox。使用 ComboBox 您可以限制可见项目的数量。