Ver código fonte

Git it to switch scenes to a nothing scene

NedRedmond 6 anos atrás
pai
commit
0fb5ff2727

+ 79
- 81
src/main/java/rocks/zipcode/atm/CashMachineApp.java Ver arquivo

@@ -1,12 +1,8 @@
1 1
 package rocks.zipcode.atm;
2 2
 
3
-import javafx.event.ActionEvent;
4
-import javafx.event.EventHandler;
5
-import javafx.geometry.Insets;
6
-import javafx.geometry.Pos;
7
-import javafx.scene.control.Label;
8
-import javafx.scene.layout.GridPane;
9
-import javafx.scene.layout.StackPane;
3
+import com.jfoenix.controls.JFXButton;
4
+import javafx.fxml.FXML;
5
+import javafx.fxml.FXMLLoader;
10 6
 import rocks.zipcode.atm.bank.Bank;
11 7
 import javafx.application.Application;
12 8
 import javafx.scene.Parent;
@@ -18,89 +14,91 @@ import javafx.scene.layout.VBox;
18 14
 import javafx.stage.Stage;
19 15
 import javafx.scene.layout.FlowPane;
20 16
 
17
+import java.io.IOException;
18
+
21 19
 /**
22 20
  * @author ZipCodeWilmington
23 21
  */
24 22
 public class CashMachineApp extends Application {
25
-    private Stage window;
26
-    Scene mainContent, loginScene;
27
-    private TextField field = new TextField();
28
-    private CashMachine cashMachine = new CashMachine(new Bank());
29 23
 
30 24
     @Override
31 25
     public void start(Stage stage) throws Exception {
32
-        window = stage;
33
-        window.setTitle("Zip Cloud Bank");
34
-
35
-
36
-        //Log In Layout
37
-        Label loginLabel = new Label("Welcome to Zip Cloud Bank!\nPlease log in.");
38
-        Button btnLogIn = new Button("Log In");
39
-        btnLogIn.setStyle("-fx-font-size: 15pt");
40
-        btnLogIn.setOnAction(e -> {
41
-            mainContent = new Scene(mainContent());
42
-            window.setScene(mainContent);
43
-        });
44
-
45
-        GridPane loginLayout = new GridPane();
46
-        loginLayout.setHgap(12);
47
-        loginLayout.setVgap(12);
48
-        loginLayout.setAlignment(Pos.CENTER);
49
-        loginLayout.getChildren().addAll(loginLabel, field, btnLogIn);
50
-
51
-        loginScene = new Scene(loginLayout,600, 600);
52
-        window.setScene(loginScene);
53
-
54
-
55
-        window.show();
26
+        FXMLLoader loader = new FXMLLoader();
27
+
28
+        stage.setTitle("Zip Cloud Bank");
29
+
30
+        //        Is this cheating?
31
+        Parent start = loader.load(getClass().getResource("/LoginScreen.fxml"));
32
+        Scene content = new Scene(start);
33
+        stage.setScene(content);
34
+        stage.show();
35
+
36
+
37
+//        //Log In Layout
38
+//        Label loginLabel = new Label("Welcome to Zip Cloud Bank!\nPlease log in.");
39
+//        Button btnLogIn = new Button("Log In");
40
+//        btnLogIn.setStyle("-fx-font-size: 15pt");
41
+//        btnLogIn.setOnAction(e -> {
42
+//            mainContent = new Scene(mainContent());
43
+//            window.setScene(mainContent);
44
+//        });
45
+//
46
+//        GridPane loginLayout = new GridPane();
47
+//        loginLayout.setHgap(12);
48
+//        loginLayout.setVgap(12);
49
+//        loginLayout.setAlignment(Pos.CENTER);
50
+//        loginLayout.getChildren().addAll(loginLabel, field, btnLogIn);
51
+
52
+//        loginScene = new Scene(loginLayout,600, 600);
53
+//
56 54
     }
57 55
 
58
-    private Parent mainContent() {
59
-        VBox vbox = new VBox(10);
60
-        vbox.setPrefSize(600, 600);
61
-
62
-        TextArea areaInfo = new TextArea();
63
-
64
-        Button btnSubmit = new Button("Set Account ID");
65
-        btnSubmit.setOnAction(e -> {
66
-            int id = Integer.parseInt(field.getText());
67
-            cashMachine.login(id);
68
-
69
-            areaInfo.setText(cashMachine.toString());
70
-        });
71
-
72
-        Button btnDeposit = new Button("Deposit");
73
-        btnDeposit.setOnAction(e -> {
74
-            int amount = Integer.parseInt(field.getText());
75
-            cashMachine.deposit(amount);
76
-
77
-            areaInfo.setText(cashMachine.toString());
78
-        });
79
-
80
-        Button btnWithdraw = new Button("Withdraw");
81
-        btnWithdraw.setOnAction(e -> {
82
-            int amount = Integer.parseInt(field.getText());
83
-            cashMachine.withdraw(amount);
84
-
85
-            areaInfo.setText(cashMachine.toString());
86
-        });
87
-
88
-        Button btnExit = new Button("Log Out");
89
-        btnExit.setOnAction(e -> {
90
-            cashMachine.logOut();
91
-
92
-            areaInfo.setText(cashMachine.toString());
93
-        });
94
-
95
-        FlowPane flowpane = new FlowPane();
96
-
97
-        flowpane.getChildren().add(btnSubmit);
98
-        flowpane.getChildren().add(btnDeposit);
99
-        flowpane.getChildren().add(btnWithdraw);
100
-        flowpane.getChildren().add(btnExit);
101
-        vbox.getChildren().addAll(field, flowpane, areaInfo);
102
-        return vbox;
103
-    }
56
+//    private Parent mainContent() {
57
+//        VBox vbox = new VBox(10);
58
+//        vbox.setPrefSize(600, 600);
59
+//
60
+//        TextArea areaInfo = new TextArea();
61
+//
62
+//        Button btnSubmit = new Button("Set Account ID");
63
+//        btnSubmit.setOnAction(e -> {
64
+//            int id = Integer.parseInt(field.getText());
65
+//            cashMachine.login(id);
66
+//
67
+//            areaInfo.setText(cashMachine.toString());
68
+//        });
69
+//
70
+//        Button btnDeposit = new Button("Deposit");
71
+//        btnDeposit.setOnAction(e -> {
72
+//            int amount = Integer.parseInt(field.getText());
73
+//            cashMachine.deposit(amount);
74
+//
75
+//            areaInfo.setText(cashMachine.toString());
76
+//        });
77
+//
78
+//        Button btnWithdraw = new Button("Withdraw");
79
+//        btnWithdraw.setOnAction(e -> {
80
+//            int amount = Integer.parseInt(field.getText());
81
+//            cashMachine.withdraw(amount);
82
+//
83
+//            areaInfo.setText(cashMachine.toString());
84
+//        });
85
+//
86
+//        Button btnExit = new Button("Log Out");
87
+//        btnExit.setOnAction(e -> {
88
+//            cashMachine.logOut();
89
+//
90
+//            areaInfo.setText(cashMachine.toString());
91
+//        });
92
+//
93
+//        FlowPane flowpane = new FlowPane();
94
+//
95
+//        flowpane.getChildren().add(btnSubmit);
96
+//        flowpane.getChildren().add(btnDeposit);
97
+//        flowpane.getChildren().add(btnWithdraw);
98
+//        flowpane.getChildren().add(btnExit);
99
+//        vbox.getChildren().addAll(field, flowpane, areaInfo);
100
+//        return vbox;
101
+//    }
104 102
 
105 103
     public static void main(String[] args) {
106 104
         launch(args);

+ 0
- 14
src/main/java/rocks/zipcode/atm/CashMachineSkin.fxml Ver arquivo

@@ -1,14 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-
3
-<?import java.lang.*?>
4
-<?import java.util.*?>
5
-<?import javafx.scene.*?>
6
-<?import javafx.scene.control.*?>
7
-<?import javafx.scene.layout.*?>
8
-
9
-<AnchorPane xmlns="http://javafx.com/javafx"
10
-            xmlns:fx="http://javafx.com/fxml"
11
-            fx:controller="rocks.zipcode.atm.CashMachineApp"
12
-            prefHeight="400.0" prefWidth="600.0">
13
-
14
-</AnchorPane>

+ 61
- 0
src/main/java/rocks/zipcode/atm/ControllerFXML.java Ver arquivo

@@ -0,0 +1,61 @@
1
+package rocks.zipcode.atm;
2
+
3
+import com.jfoenix.controls.JFXButton;
4
+import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
5
+import javafx.fxml.FXML;
6
+import javafx.fxml.FXMLLoader;
7
+import javafx.fxml.Initializable;
8
+import javafx.scene.Node;
9
+import javafx.scene.Parent;
10
+import javafx.scene.Scene;
11
+import javafx.scene.control.TextField;
12
+import javafx.scene.layout.VBox;
13
+import javafx.stage.Stage;
14
+import rocks.zipcode.atm.bank.Bank;
15
+
16
+import java.io.IOException;
17
+import java.net.URL;
18
+import java.util.ResourceBundle;
19
+
20
+
21
+
22
+public class ControllerFXML implements Initializable {
23
+
24
+    @FXML
25
+    Stage stage;
26
+
27
+    @FXML
28
+    private VBox content;
29
+
30
+    @FXML
31
+    private TextField field = new TextField();
32
+
33
+    @FXML
34
+    private CashMachine cashMachine = new CashMachine(new Bank());
35
+
36
+    @FXML
37
+    public JFXButton btnLogin;
38
+
39
+    @FXML void loginAction() throws IOException {
40
+        FXMLLoader loader = new FXMLLoader();
41
+
42
+//        try {
43
+//            mainContent = loader.load(getClass().getResource("/AccountScreen.fxml"));
44
+//            System.out.println("tried");
45
+//        } catch (IOException e) {
46
+//            e.printStackTrace();
47
+//            System.out.println("caught");
48
+//        }
49
+//        Scene accountView = new Scene(mainContent);
50
+
51
+        content.getChildren().setAll((Node) loader.load(getClass().getResource("/AccountScreen.fxml")));
52
+
53
+//        this.stage.setScene(accountView);
54
+//        this.stage.show();
55
+    }
56
+
57
+    @Override
58
+    public void initialize(URL location, ResourceBundle resources) {
59
+
60
+    }
61
+}

+ 10
- 0
src/main/resources/AccountScreen.fxml Ver arquivo

@@ -0,0 +1,10 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+
3
+<?import java.lang.*?>
4
+<?import java.util.*?>
5
+<?import javafx.scene.*?>
6
+<?import javafx.scene.control.*?>
7
+<?import javafx.scene.layout.*?>
8
+
9
+<VBox prefHeight="400.0" prefWidth="450.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="rocks.zipcode.atm.ControllerFXML">
10
+</VBox>

+ 74
- 0
src/main/resources/LoginScreen.fxml Ver arquivo

@@ -0,0 +1,74 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+
3
+<?import javafx.scene.paint.*?>
4
+<?import javafx.geometry.*?>
5
+<?import javafx.scene.text.*?>
6
+<?import com.jfoenix.controls.*?>
7
+<?import java.lang.*?>
8
+<?import java.util.*?>
9
+<?import javafx.scene.*?>
10
+<?import javafx.scene.control.*?>
11
+<?import javafx.scene.layout.*?>
12
+
13
+<VBox fx:id="content" prefHeight="400.0" prefWidth="450.0" style="-fx-border-color: coral; -fx-border-width: 12; -fx-border-radius: 1; -fx-border-insets: 5;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="rocks.zipcode.atm.ControllerFXML">
14
+   <children>
15
+      <FlowPane alignment="BOTTOM_CENTER" prefHeight="200.0" prefWidth="200.0">
16
+         <children>
17
+            <Label alignment="CENTER" contentDisplay="CENTER" maxWidth="1.7976931348623157E308" prefHeight="24.0" text="Welcome to Zip Cloud Bank" textAlignment="CENTER" textFill="CORAL" wrapText="true">
18
+               <font>
19
+                  <Font name="Futura Bold" size="24.0" />
20
+               </font>
21
+            </Label>
22
+         </children>
23
+      </FlowPane>
24
+      <FlowPane alignment="BOTTOM_CENTER" hgap="9.0" prefHeight="200.0" prefWidth="200.0">
25
+         <children>
26
+            <Label alignment="BOTTOM_RIGHT" contentDisplay="CENTER" maxWidth="1.7976931348623157E308" prefHeight="24.0" text="Email:" textAlignment="CENTER" wrapText="true">
27
+               <font>
28
+                  <Font name="Futura Medium" size="18.0" />
29
+               </font>
30
+            </Label>
31
+            <JFXTextField focusColor="CORAL">
32
+               <font>
33
+                  <Font name="Futura Medium" size="18.0" />
34
+               </font>
35
+            </JFXTextField>
36
+         </children>
37
+         <VBox.margin>
38
+            <Insets />
39
+         </VBox.margin>
40
+         <padding>
41
+            <Insets bottom="8.0" />
42
+         </padding>
43
+      </FlowPane>
44
+      <FlowPane alignment="TOP_CENTER" hgap="9.0" prefHeight="200.0" prefWidth="200.0">
45
+         <children>
46
+            <Label alignment="BOTTOM_RIGHT" contentDisplay="CENTER" maxWidth="1.7976931348623157E308" prefHeight="24.0" text="PIN:" textAlignment="CENTER" wrapText="true">
47
+               <font>
48
+                  <Font name="Futura Medium" size="18.0" />
49
+               </font>
50
+            </Label>
51
+            <JFXPasswordField focusColor="CORAL">
52
+               <font>
53
+                  <Font name="Futura Medium" size="18.0" />
54
+               </font>
55
+            </JFXPasswordField>
56
+         </children>
57
+         <padding>
58
+            <Insets top="8.0" />
59
+         </padding>
60
+      </FlowPane>
61
+      <FlowPane alignment="TOP_CENTER" prefHeight="200.0" prefWidth="200.0">
62
+         <children>
63
+            <JFXButton fx:id="btnLogin" alignment="CENTER" onAction="#loginAction" style="-fx-background-color: coral;" text="Log In" textFill="WHITE">
64
+               <font>
65
+                  <Font name="Futura Medium" size="18.0" />
66
+               </font>
67
+            </JFXButton>
68
+         </children>
69
+      </FlowPane>
70
+   </children>
71
+   <opaqueInsets>
72
+      <Insets />
73
+   </opaqueInsets>
74
+</VBox>