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)?
FX Markup Language. In the same way that HTML is for Hypertext Markup Language, and many more acronyms that end in ML .
The xmlns:fx attribute is always required and specifies the fx namespace. The remainder of the code controls the alignment and spacing of the grid pane. The alignment property changes the default position of the grid from the top left of the scene to the center.
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}" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With