I'm trying to create a set of custom control using JavaFX 8. I'm a bit confused on what are the right way to do some stuff like laying out the children I define to build my control. I use to override the layoutChildren() method, where I relocate and resize the children; but reading the javadoc for the layoutChildren() there is written:
Invoked during the layout pass to layout the children in this Parent. By default it will only set the size of managed, resizable content to their preferred sizes and does not do any node positioning.
So, according the documentation, I must not perform any relocation ("node positioning") of the children.
What I'm trying to understand is what is the right way to position and resize the children in my custom control.
Another thing I don't understand is when and how many times layoutChildren() is called; documentation says "Invoked during the layout pass" but I don't understand when "layout pass" is performed.
I hope you can help me.
EDIT @James_D
This is an example what I said in the comment
public class MyControl extends TextField {
private Label label;
public MyControl() {
super();
setSkin(new TextFieldSkin(this));
label=new Label("This is my custom textfield");
getChildren().add(label);
}
@Override
protected void layoutChildren() {
super.layoutChildren();
label.relocate(0, -label.getHeight());
System.out.println("I'm laying out children");
}
}
If you run it, you will notice that layoutChildren() is called every frames