Javafx combobox not updating dropdown size upon change on realtime?

前端 未结 5 619
一整个雨季
一整个雨季 2021-02-09 13:00

I am using Javafx v8.0.25-b18.

The problem I occur is that the size of the dynamic combox\'s dropdown list doesn\'t change, so if I had initially two items in the dropdo

5条回答
  •  一个人的身影
    2021-02-09 13:31

    I had same problem and I solved it with a quick trick. Just try to show and immediately hide !

    add.setOnAction(new EventHandler() {
      @Override
      public void handle(ActionEvent event) {
        box.getItems().add("Item " + index++);
        box.getItems().add("Item " + index++);
        box.show();
        box.hide();
      }
    });
    

提交回复
热议问题