Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8092747

[ComboBox] Popup does not respond to visibleRowCountProperty after it was shown for the first time



    • Bug
    • Resolution: Fixed
    • P4
    • 8u40
    • 8u5, 8u20
    • javafx
    • None
    • Windows 7 SP 1 64bit
      Java 8u5 (32bit) released version
      Java 8u20 b23 (32bit)


      The visibleRowCountProperty of a ComboBox only seems to have an affect on the popup of the combo box if the value is set before the popup is opened for the first time. Any changes applied afterwards do not have any effect on the reopened popup of a combo box.

      Below is a piece of code which shows this behavior.

      Explanation for the example:
      If you open the combo box without clicking on the button, a popup with two elements is shown. As soon as you click on the button, the items of the combo box are replaced by a list containing four elements and the visible row count is set to 4 which is reflected by the right label. However, when you open the popup of the combo box, the height is still the one for two rows.
      You could also press the button first, open the combo box, press the button again and open the combo box again to simulate the behavior when the visible row count is larger at the beginning and reduced after the popup was shown. In this case, the popup is always high enough for four items.

      import java.util.Arrays;

      import javafx.application.Application;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ComboBox;
      import javafx.scene.control.Label;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;

      public class ComboBoxVisibleRowCountSample extends Application {

          public static void main(String[] args) {

          public void start(Stage primaryStage) {
              ObservableList<Integer> fourItemsObservableList = FXCollections.observableList(Arrays.asList(2, 3, 4, 5));
              ObservableList<Integer> twoItemsObservableList = FXCollections.observableList(Arrays.asList(7, 8));

              ComboBox<Integer> comboBox = new ComboBox<>(twoItemsObservableList);

              Button button = new Button("Change items of combo box");
              button.setOnAction(event -> {
                  ObservableList<Integer> observableList;
                  if (comboBox.getItems().equals(fourItemsObservableList)) {
                      observableList = twoItemsObservableList;
                  } else {
                      observableList = fourItemsObservableList;

              Label visibleRowCountLabel = new Label();
              visibleRowCountLabel.textProperty().bind(new SimpleStringProperty("visible row count: ").concat(comboBox.visibleRowCountProperty().asString()));

              HBox root = new HBox(20, comboBox, button, visibleRowCountLabel);

              Scene scene = new Scene(root, 400, 150);


        Issue Links



              msladecek Martin Sládeček
              duke J. Duke
              0 Vote for this issue
              3 Start watching this issue