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

ComboBox dropdown width is computed incorrectly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8u60
    • 8u45
    • javafx
    • Mac OS X 10.10
      Java 8u45

      Sometimes the dropdown width is too narrow. Possibly related to RT-28876.
      Here's a test case, follow the instructions in the UI.

      /* ComboBox dropdown width issue */
      package comboboxwidth;

      import javafx.application.Application;
      import javafx.geometry.Insets;
      import javafx.scene.Scene;
      import javafx.scene.control.ComboBox;
      import javafx.scene.control.Label;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.Priority;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class ComboBoxWidth extends Application {
          
          @Override
          public void start(Stage primaryStage) {
              ComboBox<String> combo = new ComboBox<>();
              combo.setMaxWidth(Double.MAX_VALUE);
              combo.getItems().addAll("1","2","3","4","5","6","7","8","9","10");
              combo.setEditable(true);
              VBox vbox = new VBox(4);
              vbox.setPadding(new Insets(4));
              HBox hbox = new HBox(4);
              HBox.setHgrow(combo, Priority.ALWAYS);
              hbox.getChildren().addAll(new Label("ComboBox:"), combo);
              vbox.getChildren().addAll(
                      new Label("Open the drop down.\n"
                              + "Stretch this window wider.\n"
                              + "Open the drop down again.\n"
                              + "Then open the drop down a third time.\n"
                              + "Immediately after the the resize, the\n"
                              + "comboBox's drop down is the wrong size."),
                      hbox,
                      new Label(System.getProperty("java.version"))
              );
              Scene scene = new Scene(vbox, 300, 250);
              primaryStage.setTitle("ComboBox Width Test");
              primaryStage.setScene(scene);
              primaryStage.show();
          }

          public static void main(String[] args) { launch(args); }
      }

            jgiles Jonathan Giles
            swpalmer Scott Palmer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: