JavaFX组合框未刷新可见行数 [英] JavaFX combobox not refreshing the number of visible rows

查看:388
本文介绍了JavaFX组合框未刷新可见行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在动态更改组合框上的项目。除非可见行的数量根据第一次组合框被点击保持不变。

I'm changing the items on a combo-box dynamically. It's working perfectly, except that the number of visible rows remains fixed according to the first time the combo-box is clicked.

示例:组合框项目设置为A, B.当我点击组合框,它显示2行与A和B.
然后我动态地改变项目为C,D和E.当我点击组合框,它显示2行与C和D和一个滚动条。

Example: The combobox items are set to A and B. When I click the combobox, it shows 2 rows with A and B. Then I change dynamically the items to C, D and E. When I click the combobox, it shows 2 rows with C and D and a scrollbar.

我已经设置了

I already set the

comboBox.setVisibleRowCount(10);

但它只显示2行和滚动条。

but it keeps showing only 2 rows and a scrollbar.

如果我做相反的事情,首先将项目设置为C,D和E,然后单击组合框;它显示三个可见行。
然后我动态地改变项目到A和B.当我单击组合框,它显示3行! A,B和一个空白行。

If I do the opposite, first set the items to C, D and E and click the combobox; it shows the three visible rows. Then I change dynamically the items to A and B. When I click the combobox, it shows 3 rows! A, B and a blank row.

推荐答案

Javafx问题traker中已经提交了一个问题。 https://javafx-jira.kenai.com/browse/RT-37622

There is an issue already submitted in Javafx issue traker. https://javafx-jira.kenai.com/browse/RT-37622

它只有在组合框有固定的单元格大小时才有效。我用css。

It only works if the combobox has a fixed cell size. I did that with css.

例如:

.combo-box .list-view .list-cell{

-fx-cell-size: 35;

}

这篇关于JavaFX组合框未刷新可见行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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