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

2 columns of ComboBoxes in GridPane causes weird resizing when ComboBoxes open

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 8, 9, 10, openjfx11
    • Fix Version/s: tbd
    • Component/s: javafx
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Using Windows 10. Not tested in other OS.

      A DESCRIPTION OF THE PROBLEM :
      When there are two (or more) GridPane columns containing ComboBoxes (or any other controls using PopupControl), and that the ComboBoxes' HGrow are set ALWAYS, opening and closing any of the popups causes the whole GridPane to be resized. This only happens when the layout is not in a default calculated size.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the sample code.
      2. The application will show 2 ComboBoxes on a single row. They will have the same width.
      3. Resize the program, either by resizing the window or by maximizing the window. The 2 ComboBoxes will continue to grow and have the same width.
      4. Click on either of the 2 ComboBoxes.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The ComboBoxes will not be resized and are expected to have the same width.
      ACTUAL -
      One of the ComboBoxes is resized.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.scene.Scene;
      import javafx.scene.control.ComboBox;
      import javafx.scene.control.Label;
      import javafx.scene.layout.GridPane;
      import javafx.scene.layout.Priority;
      import javafx.stage.Stage;

      public class testFX extends Application {
      @Override
      public void start(final Stage primaryStage) throws Exception {
      final ObservableList<String> fruits = FXCollections.observableArrayList("Apple", "Banana", "Pineapple",
      "Some kind of fruit that has a very very long name");
      final GridPane root = new GridPane();
      root.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
      root.setPrefSize(GridPane.USE_COMPUTED_SIZE, GridPane.USE_COMPUTED_SIZE);

      final Label label1 = new Label("Test");
      final ComboBox<String> combo1 = new ComboBox<>(fruits);
      combo1.setMaxWidth(Double.MAX_VALUE);
      GridPane.setHgrow(label1, Priority.SOMETIMES);
      GridPane.setHgrow(combo1, Priority.ALWAYS);

      final Label label2 = new Label("Test");
      final ComboBox<String> combo2 = new ComboBox<>(fruits);
      combo2.setMaxWidth(Double.MAX_VALUE);
      GridPane.setHgrow(label2, Priority.SOMETIMES);
      GridPane.setHgrow(combo2, Priority.ALWAYS);

      root.addRow(0, label1, combo1, label2, combo2);

      final Scene sc = new Scene(root);
      primaryStage.setScene(sc);
      primaryStage.show();
      }

      public static void main(final String[] args) {
      Application.launch(args);
      }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated: