瀏覽代碼

login window appears but does nothing

mpierse 6 年之前
父節點
當前提交
bf5af0455b
共有 1 個文件被更改,包括 17 次插入19 次删除
  1. 17
    19
      src/main/java/rocks/zipcode/atm/CashMachineApp.java

+ 17
- 19
src/main/java/rocks/zipcode/atm/CashMachineApp.java 查看文件

@@ -27,9 +27,14 @@ public class CashMachineApp extends Application {
27 27
 
28 28
     private TextField field = new TextField();
29 29
     private CashMachine cashMachine = new CashMachine(new Bank());
30
+    GridPane grid;
30 31
 
31
-    public void login(Stage primaryStage){
32
-        GridPane grid = new GridPane();
32
+    Stage primaryStage = new Stage();
33
+    Scene scene1 = new Scene(login(primaryStage),400,200);
34
+    Scene scene2 = new Scene(createContent(), 500, 500);
35
+
36
+    public Parent login(Stage primaryStage){
37
+        grid = new GridPane();
33 38
         grid.setAlignment(Pos.CENTER);
34 39
         grid.setHgap(10);
35 40
         grid.setVgap(10);
@@ -41,28 +46,18 @@ public class CashMachineApp extends Application {
41 46
         hbButton.getChildren().add(btn);
42 47
         grid.add(hbButton,1,4);
43 48
 
44
-        final Text actiontarget = new Text();
45
-        grid.add(actiontarget,1,6);
46
-
47
-        btn.setOnAction(new EventHandler<ActionEvent>() {
48
-            @Override
49
-            public void handle(ActionEvent event) {
50
-                createContent();
51
-
52
-            }
53
-        });
54
-
55
-
56
-        Scene scene = new Scene(grid, 300, 275);
57
-        primaryStage.setScene(scene);
49
+        //btn.setOnAction(e->primaryStage.setScene(scene2));
50
+        primaryStage.setScene(scene1);
58 51
         primaryStage.setTitle("Welcome to Zip Cloud Bank");
59 52
         Label userID = new Label("User I.D.");
60 53
         grid.add(userID,0,1);
61 54
         TextField userTextField = new TextField();
62 55
         grid.add(userTextField,1,1);
56
+        btn.setOnAction(e->primaryStage.setScene(scene2));
57
+       return grid;
63 58
     }
64 59
 
65
-    private Parent createContent() {
60
+    public Parent createContent() {
66 61
         VBox vbox = new VBox(10);
67 62
         vbox.setPrefSize(600, 600);
68 63
 
@@ -110,8 +105,11 @@ public class CashMachineApp extends Application {
110 105
     }
111 106
 
112 107
     @Override
113
-    public void start(Stage stage) throws Exception {
114
-        stage.setScene(new Scene(createContent()));
108
+    public void start(Stage stage){
109
+        this.primaryStage = stage;
110
+        stage.setTitle("Zip Cloud Bank");
111
+        stage.setScene(scene1);
112
+        stage.isResizable();
115 113
         stage.show();
116 114
     }
117 115