Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. /* CST 242 - GUI
  2. * Duffy, Sean
  3. * Notes
  4. *
  5. * *He actually started writing on the Blackboard for this shit so excuse my text diagram he started going crazy at the end with connections*
  6. *
  7. * {D} Diamond = Composition / Aggregation read as "has a"
  8. * {I} Inheritance "is a"
  9. * {#} Number of connections
  10. * [ ] = Class
  11. *
  12. * <--> Connection
  13. *
  14. *
  15. * [Parent]
  16. * V
  17. * {D1}
  18. * [Stage]{D1} <-- [Scene]{D1} <-- [Pane]{I} <-- [HBox / VBox / BoarderPane / FlowPane / StackPane / GridPane]
  19. * {D1} {D1}
  20. * ^ ^
  21. * l------------[Node]{I} <-- [Shape]{I} <-- [Circle / Arc / Text]
  22. * l {I}
  23. * l ^
  24. * l [ImageView]
  25. * l
  26. * l
  27. * [Parent]{I} <-- [Control]{I} <-- [Button / Label / TextField / TextArea]
  28. * {I}
  29. * ^
  30. * [Group]
  31. *
  32. *
  33. */
  34.  
  35. package p1;
  36.  
  37. import javafx.application.Application;
  38. import javafx.application.Platform;
  39. import javafx.geometry.Pos;
  40. import javafx.scene.Scene;
  41. import javafx.scene.control.Button;
  42. import javafx.scene.layout.HBox;
  43. import javafx.stage.Stage;
  44.  
  45. public class Demo extends Application {
  46.  
  47. // Entry Point of the entire Application
  48.  
  49. @Override
  50. public void start(Stage primaryStage) throws Exception {
  51.  
  52. // Create Controls
  53. Button okBtn = new Button("Hello");
  54. Button exitBtn = new Button("Goodbye");
  55.  
  56. // Set the width of the button. Default width is the base requirement to
  57. // fit the text
  58. okBtn.setPrefWidth(100);
  59. exitBtn.setPrefWidth(100);
  60.  
  61. // Pane Subclass: HBox
  62. // Set the Container for the buttons on the window as well as the
  63. // esthetics
  64. HBox rootContainer = new HBox(20);
  65. rootContainer.setAlignment(Pos.CENTER);
  66. rootContainer.getChildren().addAll(okBtn, exitBtn);
  67.  
  68. // Action listener
  69. okBtn.setOnAction(e -> {
  70. Button btn = new Button("Hello");
  71. Stage stage2 = new Stage();
  72. stage2.setScene(new Scene(btn, 100, 50));
  73. stage2.show();
  74. });
  75.  
  76. exitBtn.setOnAction(e -> {
  77. Button btn = new Button("Goodbye");
  78. Stage stage2 = new Stage();
  79. stage2.setScene(new Scene(btn, 100, 50));
  80. stage2.show();
  81.  
  82. });
  83.  
  84. // Create Scene and Set dimentions
  85. Scene scene = new Scene(rootContainer, 400, 300);
  86.  
  87. // Place the Scene on the Stage
  88. primaryStage.setScene(scene);
  89.  
  90. // show Primary Stage
  91. primaryStage.setTitle("Hello World");
  92.  
  93. // Resizable by default is always TRUE
  94. primaryStage.setResizable(false);
  95. primaryStage.show();
  96.  
  97. // To fully shut down the program use
  98. // Platform.exit();
  99.  
  100. }
  101.  
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement