-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: created a HeaderView component and made App work with JavaFX
- Loading branch information
Showing
7 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package edu.group5.app.control; | ||
|
|
||
| public class HomePageController { | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,78 @@ | ||
| package edu.group5.app.view.homepage; | ||
|
|
||
| public class HeaderView { | ||
| import edu.group5.app.App; | ||
| import javafx.geometry.Pos; | ||
| import javafx.scene.control.Button; | ||
| import javafx.scene.image.Image; | ||
| import javafx.scene.image.ImageView; | ||
| import javafx.scene.layout.*; | ||
|
|
||
| public class HeaderView extends BorderPane { | ||
| private final App app; | ||
|
|
||
| public HeaderView(App app) { | ||
| this.app = app; | ||
| getStylesheets().add(getClass().getResource("/homepage/header.css").toExternalForm()); | ||
| setId("header"); | ||
|
|
||
| setLeft(getLogoSection()); | ||
| setCenter(getNavBar()); | ||
| setRight(getProfileSection()); | ||
| } | ||
|
|
||
| private StackPane getLogoSection() { | ||
| StackPane logoSection = new StackPane(); | ||
| logoSection.setId("logo-section"); | ||
| logoSection.setAlignment(Pos.CENTER); | ||
| logoSection.setOnMouseClicked(e -> System.out.println("logoSection")); | ||
| logoSection.setStyle("-fx-cursor: hand;"); | ||
|
|
||
| ImageView logo = new ImageView( | ||
| new Image(getClass().getResource("/homepage/hmh-logo.png").toExternalForm()) | ||
| ); | ||
| logo.setFitHeight(60); | ||
| logo.setPreserveRatio(true); | ||
|
|
||
| logoSection.getChildren().add(logo); | ||
| return logoSection; | ||
| } | ||
|
|
||
| private HBox getNavBar() { | ||
| HBox navbar = new HBox(); | ||
| navbar.setId("navbar"); | ||
| navbar.setAlignment(Pos.CENTER); | ||
| navbar.setSpacing(10); | ||
|
|
||
| Button home = new Button("Home"); | ||
| home.setOnAction(e -> System.out.println("Home")); | ||
| home.setStyle("-fx-cursor: hand;"); | ||
|
|
||
| Button causes = new Button("Causes"); | ||
| causes.setOnAction(e -> System.out.println("Causes")); | ||
| causes.setStyle("-fx-cursor: hand;"); | ||
|
|
||
| Button about = new Button("About us"); | ||
| about.setOnAction(e -> System.out.println("About us")); | ||
| about.setStyle("-fx-cursor: hand;"); | ||
|
|
||
| navbar.getChildren().addAll(home, causes, about); | ||
| return navbar; | ||
| } | ||
|
|
||
| private StackPane getProfileSection() { | ||
| StackPane profileSection = new StackPane(); | ||
| profileSection.setId("profile-section"); | ||
| profileSection.setAlignment(Pos.CENTER); | ||
| profileSection.setOnMouseClicked(e -> System.out.println("profileSection")); | ||
| profileSection.setStyle("-fx-cursor: hand;"); | ||
|
|
||
| ImageView avatar = new ImageView( | ||
| new Image(getClass().getResource("/homepage/avatar.png").toExternalForm()) | ||
| ); | ||
| avatar.setFitHeight(60); | ||
| avatar.setPreserveRatio(true); | ||
|
|
||
| profileSection.getChildren().add(avatar); | ||
| return profileSection; | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,11 @@ | ||
| package edu.group5.app.view.homepage; | ||
|
|
||
| public class HomePageView { | ||
| import edu.group5.app.App; | ||
| import javafx.scene.layout.BorderPane; | ||
|
|
||
| public class HomePageView extends BorderPane { | ||
| public HomePageView(App app) { | ||
| HeaderView headerView = new HeaderView(app); | ||
| setTop(headerView); | ||
| } | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #header { | ||
| -fx-background-color: #A6CDF2; | ||
| -fx-padding: 10px; | ||
| } | ||
|
|
||
| #logo-section { | ||
| -fx-border-color: black; | ||
| -fx-border-width: 2px; | ||
| } | ||
|
|
||
| #navbar { | ||
| -fx-border-color: black; | ||
| -fx-border-width: 2px; | ||
| } | ||
|
|
||
| #profile-section { | ||
| -fx-border-color: black; | ||
| -fx-border-width: 2px; | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.