-
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.
Add loading and login screens with MaterialFX integration
- Loading branch information
1 parent
fc5b81d
commit eb1afe2
Showing
8 changed files
with
171 additions
and
8 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
9 changes: 9 additions & 0 deletions
9
src/main/java/com/zpl/zpl/infrastructure/http/controller/LoadingScreenController.java
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,9 @@ | ||
package com.zpl.zpl.infrastructure.http.controller; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.control.ProgressIndicator; | ||
|
||
public class LoadingScreenController { | ||
@FXML | ||
private ProgressIndicator progressIndicator; | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/zpl/zpl/infrastructure/http/controller/#ScreenController.java
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,36 @@ | ||
package com.zpl.zpl.infrastructure.http.controller; | ||
|
||
import java.io.IOException; | ||
|
||
import com.zpl.zpl.ui.StageInitializer; | ||
|
||
import io.github.palexdev.materialfx.controls.MFXButton; | ||
import io.github.palexdev.materialfx.controls.MFXPasswordField; | ||
import io.github.palexdev.materialfx.controls.MFXTextField; | ||
import javafx.fxml.FXML; | ||
import javafx.stage.Stage; | ||
|
||
public class LoginScreenController { | ||
@FXML | ||
private MFXTextField usernameField; | ||
@FXML | ||
private MFXPasswordField passwordField; | ||
@FXML | ||
private MFXButton loginButton; | ||
|
||
private Stage stage; | ||
|
||
public void setStage(Stage stage) { | ||
this.stage = stage; | ||
} | ||
|
||
@FXML | ||
private void handleLogin() throws IOException { | ||
StageInitializer.initialize(stage); | ||
} | ||
|
||
@FXML | ||
private void handleForgotPassword() { | ||
// Add logic to handle forgotten password | ||
} | ||
} |
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,40 @@ | ||
package com.zpl.zpl.ui; | ||
|
||
import io.github.palexdev.materialfx.controls.MFXButton; | ||
import io.github.palexdev.materialfx.controls.MFXPasswordField; | ||
import io.github.palexdev.materialfx.controls.MFXTextField; | ||
import javafx.scene.Scene; | ||
import javafx.scene.layout.VBox; | ||
import javafx.stage.Stage; | ||
|
||
import java.io.IOException; | ||
|
||
public class LoginScreen { | ||
private Stage stage; | ||
|
||
public LoginScreen(Stage stage) { | ||
this.stage = stage; | ||
} | ||
|
||
public void show() { | ||
VBox root = new VBox(10); | ||
MFXTextField usernameField = new MFXTextField(); | ||
usernameField.setPromptText("Username"); | ||
MFXPasswordField passwordField = new MFXPasswordField(); | ||
passwordField.setPromptText("Password"); | ||
MFXButton loginButton = new MFXButton("Login"); | ||
|
||
loginButton.setOnAction(event -> { | ||
try { | ||
StageInitializer.initialize(stage); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
}); | ||
|
||
root.getChildren().addAll(usernameField, passwordField, loginButton); | ||
Scene scene = new Scene(root, 400, 300); | ||
stage.setScene(scene); | ||
stage.show(); | ||
} | ||
} |
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.layout.StackPane?> | ||
<?import javafx.scene.control.ProgressIndicator?> | ||
|
||
<StackPane xmlns:fx="http://javafx.com/fxml" fx:controller="com.zpl.zpl.ui.LoadingScreenController"> | ||
<ProgressIndicator /> | ||
</StackPane> |
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,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.layout.VBox?> | ||
<?import javafx.geometry.Insets?> | ||
<?import io.github.palexdev.materialfx.controls.MFXButton?> | ||
<?import io.github.palexdev.materialfx.controls.MFXPasswordField?> | ||
<?import io.github.palexdev.materialfx.controls.MFXTextField?> | ||
<?import javafx.scene.paint.Color?> | ||
<?import javafx.scene.text.Font?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.layout.HBox?> | ||
|
||
<VBox xmlns:fx="http://javafx.com/fxml" fx:controller="com.zpl.zpl.ui.LoginScreenController" spacing="15" alignment="CENTER" style="-fx-background-color: #f4f4f9; -fx-padding: 20;"> | ||
|
||
<Label text="Login" style="-fx-font-size: 24px; -fx-font-weight: bold; -fx-text-fill: #4a90e2;" /> | ||
|
||
<MFXTextField fx:id="usernameField" promptText="Username" style="-fx-font-size: 14px; -fx-border-radius: 5px; -fx-background-radius: 5px;" /> | ||
|
||
<MFXPasswordField fx:id="passwordField" promptText="Password" style="-fx-font-size: 14px; -fx-border-radius: 5px; -fx-background-radius: 5px;" /> | ||
|
||
<MFXButton text="Login" onAction="#handleLogin" style="-fx-font-size: 16px; -fx-background-color: #4a90e2; -fx-text-fill: white; -fx-border-radius: 5px;" /> | ||
|
||
<HBox alignment="CENTER" spacing="5"> | ||
<Label text="Forgot your password?" style="-fx-font-size: 12px; -fx-text-fill: #4a90e2; -fx-cursor: hand;" onMouseClicked="#handleForgotPassword"/> | ||
</HBox> | ||
</VBox> |