Add Control to StackPane : StackPane « JavaFX « Java

Add Control to StackPane

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class Main extends Application {
    public static void main(String[] args) {
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Hello World!");
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
        StackPane root = new StackPane();
        primaryStage.setScene(new Scene(root, 300, 250));;


Related examples in the same category

1.Add StackPane to a Scene and then add Scene to Stage
2.StackPane based wizard
3.Using StackPane to hold controls
4.Align the title Label at the bottom-center of the stackpane
5.Create an 8 pixel margin around a listview in the stackpane
6.Adding components to StackPane