|
@@ -3,7 +3,10 @@ package rocks.zipcode.atm;
|
3
|
3
|
import javafx.event.ActionEvent;
|
4
|
4
|
import javafx.event.Event;
|
5
|
5
|
import javafx.event.EventHandler;
|
|
6
|
+import javafx.geometry.Insets;
|
|
7
|
+import javafx.geometry.Pos;
|
6
|
8
|
import javafx.scene.control.*;
|
|
9
|
+import javafx.scene.layout.GridPane;
|
7
|
10
|
import javafx.scene.layout.HBox;
|
8
|
11
|
import rocks.zipcode.atm.bank.Bank;
|
9
|
12
|
import javafx.application.Application;
|
|
@@ -23,8 +26,12 @@ import javax.swing.*;
|
23
|
26
|
public class CashMachineApp extends Application {
|
24
|
27
|
|
25
|
28
|
private TextField field = new TextField();
|
|
29
|
+ final PasswordField passwordField = new PasswordField();
|
26
|
30
|
private CashMachine cashMachine = new CashMachine(new Bank());
|
27
|
31
|
|
|
32
|
+ Label passwordLabel = new Label ("Password: ");
|
|
33
|
+
|
|
34
|
+
|
28
|
35
|
private Parent createContent() {
|
29
|
36
|
VBox vbox = new VBox(10);
|
30
|
37
|
vbox.setPrefSize(600, 600);
|
|
@@ -39,6 +46,8 @@ public class CashMachineApp extends Application {
|
39
|
46
|
areaInfo.setText(cashMachine.toString());
|
40
|
47
|
});
|
41
|
48
|
|
|
49
|
+ passwordField.setPromptText("Enter your password");
|
|
50
|
+
|
42
|
51
|
Button btnDeposit = new Button("Deposit");
|
43
|
52
|
btnDeposit.setOnAction(e -> {
|
44
|
53
|
float amount = Float.parseFloat(field.getText());
|
|
@@ -47,16 +56,12 @@ public class CashMachineApp extends Application {
|
47
|
56
|
areaInfo.setText(cashMachine.toString());
|
48
|
57
|
});
|
49
|
58
|
|
50
|
|
- // testing Alert
|
|
59
|
+ passwordField.setOnAction(new EventHandler<ActionEvent>() {
|
|
60
|
+ @Override
|
|
61
|
+ public void handle(ActionEvent event) {
|
51
|
62
|
|
52
|
|
-// Alert withdrawAlert = new Alert(Alert.AlertType.NONE);
|
53
|
|
-// EventHandler<ActionEvent> event1 = new EventHandler<ActionEvent>() {
|
54
|
|
-// @Override
|
55
|
|
-// public void handle(ActionEvent e) {
|
56
|
|
-// withdrawAlert.show();
|
57
|
|
-//
|
58
|
|
-// }
|
59
|
|
-// };
|
|
63
|
+ }
|
|
64
|
+ });
|
60
|
65
|
|
61
|
66
|
Button btnWithdraw = new Button("Withdraw");
|
62
|
67
|
btnWithdraw.setOnAction(e -> {
|
|
@@ -94,14 +99,55 @@ public class CashMachineApp extends Application {
|
94
|
99
|
|
95
|
100
|
// HBox hbox = new HBox(passwordField);
|
96
|
101
|
|
97
|
|
- vbox.getChildren().addAll(field, flowpane, areaInfo);
|
|
102
|
+ vbox.getChildren().addAll(field, passwordLabel, passwordField, flowpane, areaInfo);
|
98
|
103
|
return vbox;
|
99
|
104
|
}
|
100
|
105
|
|
|
106
|
+
|
|
107
|
+ private Stage popUpStage() {
|
|
108
|
+ Stage login = new Stage();
|
|
109
|
+ login.setTitle("Account Login");
|
|
110
|
+
|
|
111
|
+ GridPane grid = new GridPane();
|
|
112
|
+ grid.setAlignment(Pos.CENTER);
|
|
113
|
+ grid.setHgap(10);
|
|
114
|
+ grid.setVgap(10);
|
|
115
|
+
|
|
116
|
+ grid.setPadding(new Insets(25, 25, 25, 25));
|
|
117
|
+
|
|
118
|
+ Scene scene = new Scene(grid, 300, 275);
|
|
119
|
+
|
|
120
|
+ Label userName = new Label ("Select Account");
|
|
121
|
+ grid.add(userName, 0, 1);
|
|
122
|
+ MenuItem menuItem1 = new MenuItem("Option 1 ");
|
|
123
|
+ menuItem1.setOnAction(event -> {
|
|
124
|
+
|
|
125
|
+ });
|
|
126
|
+
|
|
127
|
+ MenuButton menuButton = new MenuButton("Options", null, menuItem1);
|
|
128
|
+ grid.add(menuButton, 2, 1);
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+ login.setScene(scene);
|
|
132
|
+
|
|
133
|
+ return login;
|
|
134
|
+
|
|
135
|
+ }
|
|
136
|
+
|
101
|
137
|
@Override
|
102
|
138
|
public void start(Stage stage) throws Exception {
|
|
139
|
+
|
103
|
140
|
stage.setScene(new Scene(createContent()));
|
|
141
|
+ Stage login = popUpStage();
|
|
142
|
+
|
104
|
143
|
stage.show();
|
|
144
|
+
|
|
145
|
+ login.alwaysOnTopProperty();
|
|
146
|
+
|
|
147
|
+ login.show();
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
105
|
151
|
}
|
106
|
152
|
|
107
|
153
|
public static void main(String[] args) {
|