I hoped for a feature that would allow me to work with numbers inside the FXML. For example, tried to define the height of one element to be equal to a constant and the height of the second element to be equal to the same constant multiplied by 2 (i.e. constant * 2
). Is it possible to do it in FXML at all or do I need to do this part of view build-up inside the controller (which I would like to avoid)?
Yes, it is possible:
<?import java.lang.Double?>
...
<fx:define>
<Double fx:id="xHeight" fx:value="100" />
</fx:define>
...
<Label fx:id="lblElementOne" prefHeight="$xHeight" />
<Label fx:id="lblElementTwo" prefHeight="${xHeight * 2}" />