JDK-8210037 : 2 columns of ComboBoxes in GridPane causes weird resizing when ComboBoxes open
  • Type: Bug
  • Component: javafx
  • Sub-Component: scenegraph
  • Affected Version: 8,9,10,openjfx11
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: x86_64
  • Submitted: 2018-08-27
  • Updated: 2018-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
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



Comments
Just for the record, observed more re-sizing of the combobox. Steps: 1. Run sample 2. Maximize 3. Click second combobox => causes resize. 4. Select an item from options, again causes resize 5. Click on first combobox, again causes resize 6. Select an item from options, again causes resize
31-08-2018

Since this is likely a layout issue with GridPane, I am changing the subcomponent to scenegraph. If it turns out to be a problem in ComboBox, it can be moved back to controls.
29-08-2018

works fine with root.setMaxSize(Double.MAX_VALUE - 1, Double.MAX_VALUE -1); so looks like an overflow issue somewhere on the layout size calculation path
28-08-2018

Windows 10, 64-bit JDK Issue is reproducible in all releases of JDK - 8b132, 8u181, 8u192 & latest openjfx build. Steps to reproduce: 1. Run test case and maximise the window. 2. Now Click on second combobox. Second comboBox will again resize.
28-08-2018