From b806b03aba39bd8e7ed7c18db02a55b80413c3fc Mon Sep 17 00:00:00 2001 From: Sage The DM Date: Tue, 5 Nov 2024 10:01:11 +0100 Subject: [PATCH] working thing --- .../src/main/java/com/example/App.java | 132 +++++++++++++++++- .../target/classes/com/example/App.class | Bin 4127 -> 8886 bytes 2 files changed, 127 insertions(+), 5 deletions(-) diff --git a/Code/ost/_05_layouts/src/main/java/com/example/App.java b/Code/ost/_05_layouts/src/main/java/com/example/App.java index 1248f16..23bfb5f 100644 --- a/Code/ost/_05_layouts/src/main/java/com/example/App.java +++ b/Code/ost/_05_layouts/src/main/java/com/example/App.java @@ -2,11 +2,19 @@ package com.example; import javafx.application.Application; +import javafx.geometry.HPos; import javafx.geometry.Insets; import javafx.geometry.Pos; +import javafx.geometry.VPos; import javafx.scene.Scene; import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextArea; +import javafx.scene.control.TextField; import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.ColumnConstraints; +import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; import javafx.scene.layout.StackPane; @@ -29,7 +37,46 @@ public class App extends Application { @Override public void start(Stage stage) { this.primaryStage = stage; - showStackPane(); // Change this line to launch a different scene + showMain(); // Change this line to launch a different scene + } + + // #region main scene + private void showMain() { + // Create a VBox to hold the buttons + VBox mainLayout = new VBox(10); + mainLayout.setPadding(new Insets(20)); + mainLayout.setAlignment(Pos.CENTER); + + // Create buttons for each scene + Button hBoxButton = new Button("Go to HBox Scene"); + Button anchorPaneButton = new Button("Go to AnchorPane Scene"); + Button vBoxButton = new Button("Go to VBox Scene"); + Button stackPaneButton = new Button("Go to StackPane Scene"); + Button borderPaneButton = new Button("Go to BorderPane Scene"); + Button gridPaneButton = new Button("Go to GridPane Scene"); + + // Set action for each button to switch scenes + hBoxButton.setOnAction(e -> showHBoxScene()); + anchorPaneButton.setOnAction(e -> showAnchorPaneScene()); + vBoxButton.setOnAction(e -> showVBoxScene()); + stackPaneButton.setOnAction(e -> showStackPane()); + borderPaneButton.setOnAction(e -> showBorderPane()); + gridPaneButton.setOnAction(e -> showGridPane()); + + // Add buttons to the layout + mainLayout.getChildren().addAll( + hBoxButton, + anchorPaneButton, + vBoxButton, + stackPaneButton, + borderPaneButton, + gridPaneButton); + + // Create the scene with the main layout + Scene scene = new Scene(mainLayout, 300, 300); + primaryStage.setTitle("Main Scene"); + primaryStage.setScene(scene); + primaryStage.show(); } // #region HBox Scene @@ -51,7 +98,6 @@ public class App extends Application { primaryStage.setScene(scene); primaryStage.show(); } - // #endregion // #region AnchorPane Scene private void showAnchorPaneScene() { @@ -77,7 +123,6 @@ public class App extends Application { primaryStage.setScene(scene); primaryStage.show(); } - // #endregion // #region VBox Scene private void showVBoxScene() { @@ -100,7 +145,6 @@ public class App extends Application { primaryStage.setScene(scene); primaryStage.show(); } - // #endregion // #region StackPane Scene private void showStackPane() { @@ -126,5 +170,83 @@ public class App extends Application { primaryStage.setScene(scene); primaryStage.show(); } - // #endregion + + // #region borderPane Scene + private void showBorderPane() { + BorderPane borderPane = new BorderPane(); + borderPane.setPadding(new Insets(10, 20, 20, 20)); + + // Create buttons + Button topButton = new Button("Top"); + Button bottomButton = new Button("Bottom"); + Button leftButton = new Button("Left"); + Button rightButton = new Button("Right"); + + // Create a TextArea + TextArea textArea = new TextArea(); + textArea.setWrapText(true); + + // Set the layout of the BorderPane + borderPane.setTop(topButton); + borderPane.setBottom(bottomButton); + borderPane.setLeft(leftButton); + borderPane.setRight(rightButton); + borderPane.setCenter(textArea); + BorderPane.setMargin(textArea, new Insets(10, 10, 10, 10)); + BorderPane.setAlignment(topButton, Pos.CENTER); + BorderPane.setAlignment(bottomButton, Pos.CENTER); + BorderPane.setAlignment(leftButton, Pos.CENTER); + BorderPane.setAlignment(rightButton, Pos.CENTER); + + // Set scene + Scene scene = new Scene(borderPane, 550, 250); + primaryStage.setTitle("BorderPane Scene"); + primaryStage.setScene(scene); + primaryStage.show(); + } + + // #region GridPane Scene + private void showGridPane() { + // Create a GridPane with padding and gaps + GridPane gridPane = new GridPane(); + gridPane.setPadding(new Insets(15)); + gridPane.setHgap(15); + gridPane.setVgap(15); + + // Create labels, button, text fields, and text area + Label nameLabel = new Label("Name:"); + Label emailLabel = new Label("EMAILs:"); + Label commentLabel = new Label("Comment:"); + Button submitButton = new Button("Submit"); + TextField nameTextField = new TextField(); + TextField emailTextField = new TextField(); + TextArea commentTextArea = new TextArea(); + commentTextArea.setWrapText(true); + + // Add controls to the GridPane + gridPane.add(nameLabel, 0, 0); // Column 0, Row 0 + gridPane.add(emailLabel, 0, 1); // Column 0, Row 1 + gridPane.add(commentLabel, 0, 2); // Column 0, Row 2 + gridPane.add(nameTextField, 1, 0); // Column 1, Row 0 + gridPane.add(emailTextField, 1, 1); // Column 1, Row 1 + gridPane.add(commentTextArea, 1, 2); // Column 1, Row 2 + gridPane.add(submitButton, 1, 3); // Column 1, Row 3 + + // Align controls + GridPane.setValignment(commentLabel, VPos.TOP); + GridPane.setHalignment(submitButton, HPos.RIGHT); + + // Set column constraints + ColumnConstraints columnConstraints1 = new ColumnConstraints(); + columnConstraints1.setPercentWidth(33); + ColumnConstraints columnConstraints2 = new ColumnConstraints(); + columnConstraints2.setPercentWidth(67); + gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2); + + // Set scene + Scene scene = new Scene(gridPane, 300, 300); + primaryStage.setTitle("GridPane Scene"); + primaryStage.setScene(scene); + primaryStage.show(); + } } diff --git a/Code/ost/_05_layouts/target/classes/com/example/App.class b/Code/ost/_05_layouts/target/classes/com/example/App.class index 873f5c2bc5956fbcfcb96b0ce9d0f06b0d87d6e6..38609e32a0b59e14abd27a701e21d0da9800530f 100644 GIT binary patch literal 8886 zcmb7J4SZD9l|Lt$nKzj{K1`x@R3s?XgaifMXeuITScv_Vzr`9A`y$)+Sa1B^|Phg{&sD<+b!$1+HGxj+y2kJ^X4mqb~V2@ z=iPVjx##}R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