1  import javafx.application.Application;
  2  import javafx.geometry.Insets;
  3  import javafx.scene.Scene;
  4  import javafx.scene.control.Label;
  5  import javafx.scene.layout.BorderPane;
  6  import javafx.scene.layout.StackPane;
  7  import javafx.stage.Stage;
  8  
  9  public class ShowBorderPane extends Application {
 10    @Override // Override the start method in the Application class
 11    public void start(Stage primaryStage) {
 12      // Create a border pane 
 13      BorderPane pane = new BorderPane();
 14  
 15      // Place nodes in the pane
 16      pane.setTop(new CustomPane("Top")); 
 17      pane.setRight(new CustomPane("Right"));
 18      pane.setBottom(new CustomPane("Bottom"));
 19      pane.setLeft(new CustomPane("Left"));
 20      pane.setCenter(new CustomPane("Center")); 
 21      
 22      // Create a scene and place it in the stage
 23      Scene scene = new Scene(pane);
 24      primaryStage.setTitle("ShowBorderPane"); // Set the stage title
 25      primaryStage.setScene(scene); // Place the scene in the stage
 26      primaryStage.show(); // Display the stage
 27    }
 28  } 
 29  
 30  // Define a custom pane to hold a label in the center of the pane
 31  class CustomPane extends StackPane {
 32    public CustomPane(String title) {
 33      getChildren().add(new Label(title));
 34      setStyle("-fx-border-color: red");
 35      setPadding(new Insets(11.5, 12.5, 13.5, 14.5));
 36    }
 37  }