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