You can set the layout of nodes added to StackPane to a position in Stackpane using the StackPane.setAlignment (node) method:
Label topLeftLabel = new Label("Top Left"); StackPane stack = new StackPane(); stack.getChildren().add(topLeftLabel); StackPane.setAlignment(topLeftLabel, Pos.TOP_LEFT);
Even if possible, from your brief description of how you are trying to use StackPane, it looks like you would be better off using regular Pane , or Group or AnchorPane for such absolute positioning, wanting to achieve.
Perhaps look at using a visual tool like SceneBuilder . Even if you are not using the FXML that it outputs, SceneBuilder should give you a much better idea of how JavaFX layout mechanisms work. SceneBuilder uses AnchorPane as the default layout panel used to ensure absolute positioning of elements (which seems to be what you want to achieve).
source share