import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;

public class Test extends Application { 
	@Override 
	public void start(final Stage primaryStage) throws Exception { 
		final VBox root = new VBox(); 
		final Scene sc = new Scene(root); 
		primaryStage.setScene(sc); 
		primaryStage.show(); 

		// Platform.runLater is necessary because this start() must not be blocked (i.e. start() must finish executing) 
		Platform.runLater(() -> { 
			final Button button = new Button("Exit"); 
			button.setOnAction(e -> Platform.exit()); 

			Stage st = new Stage(); 
			st.setScene(new Scene(button)); 

			st.initOwner(primaryStage); 
			st.initModality(Modality.WINDOW_MODAL); // Just need window-level modality 

			st.showAndWait(); // Shows the "dialog" window 
		}); 
	} 

	public static void main(final String[] args) { 
		Application.launch(args); 
	} 
} 