-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChangePassword.java
More file actions
110 lines (89 loc) · 4.26 KB
/
ChangePassword.java
File metadata and controls
110 lines (89 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package com.trekmate.view.settings;
import com.trekmate.manager.SceneManager;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundImage;
import javafx.scene.layout.BackgroundPosition;
import javafx.scene.layout.BackgroundRepeat;
import javafx.scene.layout.BackgroundSize;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.util.Duration;
import javafx.animation.ScaleTransition;
import javafx.geometry.Pos;
public class ChangePassword {
private SceneManager sceneManager;
public ChangePassword(SceneManager sceneManager) {
this.sceneManager = sceneManager;
}
public Scene createScene() {
// Load the background image
Image backgroundImage = new Image("images/SettingsBg.jpg");
// Create a BackgroundImage
BackgroundImage background = new BackgroundImage(backgroundImage,
BackgroundRepeat.NO_REPEAT,
BackgroundRepeat.NO_REPEAT,
BackgroundPosition.CENTER,
new BackgroundSize(1000, 600, false, false, true, false));
// Create a Pane and set its background
Pane pane = new Pane();
pane.setBackground(new Background(background));
pane.setPrefSize(800, 600);
// Create the VBox for the new password form
VBox newPassword = new VBox(15);
newPassword.setAlignment(Pos.CENTER);
newPassword.setPadding(new javafx.geometry.Insets(50));
newPassword.setStyle("-fx-background-color: rgba(255, 255, 255, 0.8); -fx-background-radius: 10;");
// Add widgets
Label titleLabel = new Label("Reset Password");
titleLabel.setStyle("-fx-font-size: 24px; -fx-text-fill: #333333;");
Label newPasswordLabel = new Label("New Password:");
newPasswordLabel.setStyle("-fx-text-fill: #333333;");
PasswordField newPasswordField = new PasswordField();
newPasswordField.setPromptText("Enter your new password");
Label confirmPasswordLabel = new Label("Confirm Password:");
confirmPasswordLabel.setStyle("-fx-text-fill: #333333;");
PasswordField confirmPasswordField = new PasswordField();
confirmPasswordField.setPromptText("Confirm your new password");
Button changePasswordButton = new Button("Change Password");
changePasswordButton.setStyle("-fx-background-color: #007bff; -fx-text-fill: white;");
changePasswordButton.setOnAction(event -> {
if (newPasswordField.getText().equals(confirmPasswordField.getText())) {
System.out.println("Successfully Changed Password");
} else {
System.out.println("Invalid Password");
}
System.out.println("Change Password clicked");
});
// Load arrow icon
Image arrowImage = new Image(getClass().getResourceAsStream("/images/BackButtonLogo.jpg"));
ImageView arrowImageView = new ImageView(arrowImage);
arrowImageView.setFitWidth(15);
arrowImageView.setFitHeight(15);
// Back button
Button backButton = new Button("Back", arrowImageView);
backButton.setStyle("-fx-background-color: #007bff; -fx-text-fill: white;");
backButton.setOnAction(event -> {
sceneManager.switchTo("HomePage");
});
newPassword.getChildren().addAll(titleLabel, newPasswordLabel, newPasswordField, confirmPasswordLabel, confirmPasswordField, changePasswordButton, backButton);
// Position the VBox in the center of the Pane
newPassword.setLayoutX(450); // Adjust to center the form
newPassword.setLayoutY(150);
// Add the new password form and ImageView to the Pane
pane.getChildren().addAll(newPassword);
ScaleTransition scaleTransition = new ScaleTransition(Duration.seconds(5), newPassword);
scaleTransition.setFromX(1.0);
scaleTransition.setToX(1.3);
scaleTransition.setFromY(1.0);
scaleTransition.setToY(1.3);
scaleTransition.play();
// Setting the scene
return new Scene(pane, 2080, 1080);
}
}