Guest User

Untitled

a guest
Nov 22nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. package showBorderPane;
  2.  
  3. import javafx.application.Application;
  4. import javafx.geometry.Insets;
  5. import javafx.scene.Scene;
  6. import javafx.scene.control.Label;
  7. import javafx.scene.layout.BorderPane;
  8. import javafx.scene.layout.StackPane;
  9. import javafx.stage.Stage;
  10.  
  11. public class ShowBorderPane extends Application {
  12. @Override // Override the start method in the Application class
  13. public void start(Stage primaryStage){
  14.  
  15. //Create the border pane
  16. BorderPane pane = new BorderPane();
  17.  
  18. //Place nodes in the pane
  19. pane.setTop(new CustomPane("Top"));
  20. pane.setRight(new CustomPane("Right"));
  21. pane.setBottom(new CustomPane("Bottom"));
  22. pane.setLeft(new CustomPane("Left"));
  23. pane.setCenter(new CustomPane("Center"));
  24.  
  25. //Create a scene and place it in the stage
  26. Scene scene = new Scene(pane);
  27. primaryStage.setTitle("ShowBorderPane");
  28. primaryStage.setScene(scene);
  29. primaryStage.show();
  30.  
  31. }
  32.  
  33. }
  34. // Define a custom pane to hold a label in the center of the pane
  35. class CustomPane extends StackPane{
  36. public CustomPane(String title){
  37. getChildren().add(new Label(title));
  38. setStyle("-fx-border-color: red");
  39. setPadding(new Insets(11.5, 12.5, 13.5, 14.5));
  40. }
  41. }
Add Comment
Please, Sign In to add comment