Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* CST 242 - GUI
- * Duffy, Sean
- * Notes
- *
- * *He actually started writing on the Blackboard for this shit so excuse my text diagram he started going crazy at the end with connections*
- *
- * {D} Diamond = Composition / Aggregation read as "has a"
- * {I} Inheritance "is a"
- * {#} Number of connections
- * [ ] = Class
- *
- * <--> Connection
- *
- *
- * [Parent]
- * V
- * {D1}
- * [Stage]{D1} <-- [Scene]{D1} <-- [Pane]{I} <-- [HBox / VBox / BoarderPane / FlowPane / StackPane / GridPane]
- * {D1} {D1}
- * ^ ^
- * l------------[Node]{I} <-- [Shape]{I} <-- [Circle / Arc / Text]
- * l {I}
- * l ^
- * l [ImageView]
- * l
- * l
- * [Parent]{I} <-- [Control]{I} <-- [Button / Label / TextField / TextArea]
- * {I}
- * ^
- * [Group]
- *
- *
- */
- package p1;
- import javafx.application.Application;
- import javafx.application.Platform;
- import javafx.geometry.Pos;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.layout.HBox;
- import javafx.stage.Stage;
- public class Demo extends Application {
- // Entry Point of the entire Application
- @Override
- public void start(Stage primaryStage) throws Exception {
- // Create Controls
- Button okBtn = new Button("Hello");
- Button exitBtn = new Button("Goodbye");
- // Set the width of the button. Default width is the base requirement to
- // fit the text
- okBtn.setPrefWidth(100);
- exitBtn.setPrefWidth(100);
- // Pane Subclass: HBox
- // Set the Container for the buttons on the window as well as the
- // esthetics
- HBox rootContainer = new HBox(20);
- rootContainer.setAlignment(Pos.CENTER);
- rootContainer.getChildren().addAll(okBtn, exitBtn);
- // Action listener
- okBtn.setOnAction(e -> {
- Button btn = new Button("Hello");
- Stage stage2 = new Stage();
- stage2.setScene(new Scene(btn, 100, 50));
- stage2.show();
- });
- exitBtn.setOnAction(e -> {
- Button btn = new Button("Goodbye");
- Stage stage2 = new Stage();
- stage2.setScene(new Scene(btn, 100, 50));
- stage2.show();
- });
- // Create Scene and Set dimentions
- Scene scene = new Scene(rootContainer, 400, 300);
- // Place the Scene on the Stage
- primaryStage.setScene(scene);
- // show Primary Stage
- primaryStage.setTitle("Hello World");
- // Resizable by default is always TRUE
- primaryStage.setResizable(false);
- primaryStage.show();
- // To fully shut down the program use
- // Platform.exit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement