In JavaFX, is there something similar to setLayout();
or setBounds();
?
For example, I want to positioning a button to a position that I desire.
In JavaFX, is there something similar to setLayout();
or setBounds();
?
For example, I want to positioning a button to a position that I desire.
Everything on JavaFX scene graph is a Node. Each node has a X-coordinate and a Y-coordinate. But there are different ways to
set/change position
of a child component. It depends on the layout manager used to show the component on the scene graph.Group
, which do not compute child's default position and you can uselayoutX
andlayoutY
directly on themRegion
, whichautomatically
compute child's default position usinglayoutX
and inorder to adjust the locations of the components from their default positions you need to usetranslateX
andtranslateY
values.From the docs :
You should read up on the Node class (the long text at the beginning), and then especially relocate, setLayoutX (and Y) and setTranslateX (and Y).