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

ComboBox: setVisibleRowCount works incrorrecly

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • 8
    • 7u6
    • javafx
    • b15

      setVisibleRowCount does not work if called before filling of items list. The resulted height of drop-down length is much less then it should be.

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ComboBox;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class Main extends Application {

          @Override
          public void start(Stage stage) {
              VBox content = new VBox();
              final ComboBox cb = new ComboBox();
              cb.setEditable(true);
              stage.setScene(new Scene(content, 400, 400));
              Button btn = new Button("Reset");
              btn.setOnAction(new EventHandler<ActionEvent>() {
                  public void handle(ActionEvent t) {
                      cb.setVisibleRowCount(4);
                      for (int i = 0; i < 10; i++) {
                          cb.getItems().addAll(String.valueOf(i));
                      }
                  }
              });
              content.getChildren().addAll(cb, btn);
              stage.show();
          }

          public static void main(String[] args) {
              launch(Main.class, args);
          }
      }

            jgiles Jonathan Giles
            ogb Oleg Barbashov (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: