I have a problem with JavaFX(8), HBox, ComboBox and HGrow.
HGrow does not work in combination with ComboBox.
(INFO: with TextField (instead of ComboBox), it works as expected!)
This is my FXML-Code:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<VBox prefHeight="117.0" prefWidth="285.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.test.TestController">
<children>
<HBox prefHeight="105.0" prefWidth="196.0" VBox.vgrow="ALWAYS">
<children>
<ComboBox fx:id="fxCboTest" prefHeight="25.0" prefWidth="62.0" HBox.hgrow="ALWAYS" />
</children>
</HBox>
</children>
</VBox>
this Code will result in:
i also tried following code (without success, this code does nothing):
HBox.setHgrow(uiController.fxCboTest, Priority.ALWAYS);
Does anyone has an idea how to make an ComboBox HGrow?
This is an answer to my own question.
After some testing, I found out that when setting Max Width to MAX_VALUE, it works:
This will result in following code/xml from SceneBuilder:
...
<children>
<ComboBox maxWidth="1.7976931348623157E308" prefWidth="150.0" HBox.hgrow="ALWAYS" />
</children>
...
where 1.7976931348623157E308 looks like Double.MAX_VALUE.
This will also work with multiple controls in Hbox.
In my opinion, this is not very consequently/consistently.
I still don't unserstand why HGrow does not work for ComboBox.