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

ComboBox width is changed when a value is selected

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      The width of the ComboBox is changed when a value is selected.
      <LINK><ATTACHED GIF>

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the provided code. Stretch the stage width to increase the window width by approximately one and a half times. Select a value in the ComboBox.
      Code:
      public class NewMain extends Application {

           enum Test { FOO, BAR }

           @Override
           public void start(Stage stage) {
               GridPane gridPane = new GridPane();
               gridPane.setHgap(10);
               gridPane.setVgap(10);
               gridPane.setPadding(new Insets(10));

               textFieldRow(gridPane, 0);
               textFieldRow(gridPane, 1);

               Label label1 = new Label("Label AAAAA BBBBB:");
               label1.setMinWidth(Region.USE_PREF_SIZE);
               var comboBox = new ComboBox<Test>(); comboBox.setItems(FXCollections.observableArrayList(Test.values()));

               gridPane.add(label1, 0, 2);
               gridPane.add(comboBox, 1, 2);
               comboBox.setMaxWidth(Double.MAX_VALUE);

               Scene scene = new Scene(gridPane, 600, 200);
               stage.setScene(scene);
               stage.show();
           }

           private void textFieldRow(GridPane gridPane, int index) {
               Label label1 = new Label("Label AAAAA BBBBB:");
               label1.setMinWidth(Region.USE_PREF_SIZE);
               TextField textField1 = new TextField();
               GridPane.setHgrow(textField1, Priority.ALWAYS);
               textField1.setMinWidth(10);
               Label label2 = new Label("Label CCCCCC DDDDDD:");
               label2.setMinWidth(Region.USE_PREF_SIZE);
               TextField textField2 = new TextField();
               GridPane.setHgrow(textField2, Priority.ALWAYS);
               textField2.setMinWidth(10);

               gridPane.add(label1, 0, index);
               gridPane.add(textField1, 1, index);
               gridPane.add(label2, 2, index);
               gridPane.add(textField2, 3, index);
           }


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



            angorya Andy Goryachev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: