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

[Layout] ListView of a Combobox has a scrollbar even if visible row count is set to the number of elements

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • 8u40
    • 8u5
    • javafx
    • Windows 7

      We have troubles with the ListView of a Combobox, when trying to avoid showing the Scrollbar.
      Following sample illustrates the problem:

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.ComboBox;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;

      public class ComboBoxSample extends Application {

          @Override public void start(Stage stage) {

              final ComboBox testComboBoxOK = new ComboBox();
              String values[] = {"1","2","3","4","5","6","7","8","9","10","11","12"};

              testComboBoxOK.getItems().addAll(values);
              testComboBoxOK.setVisibleRowCount(values.length);

              final ComboBox testComboBoxWrong = new ComboBox();
              testComboBoxWrong.getItems().addAll(values);
              testComboBoxWrong.getItems().add("13");
              testComboBoxWrong.setVisibleRowCount(values.length + 1);

              HBox horizontalBox = new HBox();
              horizontalBox.setSpacing(10.0);
              horizontalBox.getChildren().addAll(testComboBoxOK, testComboBoxWrong);

              Scene scene = new Scene(horizontalBox, 450, 250);
              stage.setScene(scene);
              stage.show();
          }
      }

      When using a stylesheet like the one below it gets worse:

      .combo-box-popup .list-cell{
          -fx-text-fill: blue;
          -fx-background-color: yellow;
          -fx-border-color: red;
          -fx-border-width: 10 10 0 10;
      }

            jgiles Jonathan Giles
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: