You need to use StackPane as the root layout instead of using VBox. StackPane allows you to stack vertices on top of each other (z-order).
In the button action, you can create a new ProgressIndicator and add it to your StackPane. I introduced another VBox as a parent for the indicator, because I did not want the indicator to fix all available space. You can disable existing VBox, to get the effect of greying on the button action after the process is complete, you can turn on the VBox again.

import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ProgressIndicator; import javafx.scene.control.TextField; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage arg0) throws Exception { StackPane root = new StackPane(); VBox bx = new VBox(); bx.setAlignment(Pos.CENTER); TextField userName = new TextField("User Name"); userName.setMaxWidth(200); TextField email = new TextField("Email"); email.setMaxWidth(200); Button submit = new Button("Submit"); submit.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { ProgressIndicator pi = new ProgressIndicator(); VBox box = new VBox(pi); box.setAlignment(Pos.CENTER);
Itachi uchiha
source share