how to make child auto-resize (child is Pane, parent is VBox) in javafx

I have 2 questions a javafx application, I want to put the child(crosshairArea) at the left-top corner of its parent, with 1/2 width and height as well. think I can do that via override the parent function "layoutChildren" (VBox), is there other way to do that? e.g. property binding?

2.initially VBox will occupy the full scene area, how to make(relocate) it to the half-bottom of scene?

public class Crossh extends Application {

    public static void main(String[] args) {

    public void start(Stage stage) {        
        VBox root = new VBox(5);
        // root.setPadding(new Insets(20,20,20,20));

        Pane crosshairArea = new Pane();

        Scene scene = new Scene(root);
        stage.setTitle("Location Crosshair");
        stage.setHeight(700);       ;


For your first question Have you tried the height property of VBox. For example

root.heightProperty().addListener(new ChangeListener<Number>() {

        public void changed(ObservableValue<? extends Number> arg0,
                Number arg1, Number arg2) {


For your second question, you will have to put something on top of VBox to occupy the size on the top or you can set the alignment of VBox to Pos.BOTTOM

Set the VBox's last child vgrow property to true.


That will solve the problem.

Need Your Help

jQuery image scroll view with touch and marker support

jquery image mobile scrollable markers

I have a large image which should be viewed at 100% zoom and touch scrollable by the user on a mobile device (a scrollable view of 100% width of the device).

Nosetests TypeError and Attribute Error in Python (LPTHW, exercise 48)

python nosetests

I am working on Learn Python the Hard Way, Exercise 48, using nosetests to test tuples. The nosetest I have set up is as follows: