Adding components to StackPane : StackPane « JavaFX « Java

Adding components to StackPane

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
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("BorderPane Test");
    //Creating StackPane
    StackPane sp = new StackPane();
    Label lbl = new Label("JavaFX 2 StackPane");
    Button btn = new Button("Button");
    //Adding StackPane to the scene
    Scene scene = new Scene(sp,300,200);


Related examples in the same category

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