Align the title Label at the bottom-center of the stackpane : StackPane « JavaFX « Java






Align the title Label at the bottom-center of the stackpane

 
 import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class Main extends Application {

    @Override public void start(Stage stage) {
        Group group = new Group();
        Scene scene = new Scene(group); 


        Label title = new Label("Label 1");
        StackPane stackpane = new StackPane();
        StackPane.setAlignment(title, Pos.BOTTOM_CENTER);
        stackpane.getChildren().addAll(new Label("Label"), title);
        
        group.getChildren().add(stackpane);
        
        stage.setTitle("Welcome to JavaFX!"); 
        stage.setScene(scene); 
        stage.sizeToScene(); 
        stage.show(); 
    }

    public static void main(String[] args) {
        Application.launch(args);
    }
}

   
  








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.Create an 8 pixel margin around a listview in the stackpane
6.Adding components to StackPane