Browse Source

Working balance history table

NedRedmond 6 years ago
parent
commit
b749b6544d

+ 4
- 1
src/main/java/AccountController.java View File

@@ -101,6 +101,7 @@ public class AccountController {
101 101
         int amount = Integer.parseInt(amountField.getText());
102 102
 
103 103
         String type = "";
104
+        int before = CashMachine.INSTANCE.getBalance();
104 105
 
105 106
         switch (tabPane.getSelectionModel().getSelectedItem().getText())
106 107
         {
@@ -114,7 +115,9 @@ public class AccountController {
114 115
         }
115 116
         textArea.setText(CashMachine.INSTANCE.toString());
116 117
 
117
-        data.add(0, new Transaction(type, Integer.parseInt(amountField.getText()), CashMachine.INSTANCE.getBalance()));
118
+        if (CashMachine.INSTANCE.getBalance() != before) {
119
+            data.add(0, new Transaction(type, Integer.parseInt(amountField.getText()), CashMachine.INSTANCE.getBalance()));
120
+        }
118 121
     }
119 122
 
120 123
     @FXML

+ 1
- 1
src/main/java/rocks/zipcode/atm/bank/Transaction.java View File

@@ -10,7 +10,7 @@ public class Transaction {
10 10
     private int balance;
11 11
 
12 12
     public String getCurrentTime() {
13
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
13
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd-yy HH:mm");
14 14
         Date now = new Date();
15 15
         String strDate = simpleDateFormat.format(now);
16 16
         return strDate;

+ 8
- 5
src/main/resources/accountview.fxml View File

@@ -18,7 +18,7 @@
18 18
 <!--</children>-->
19 19
 <!--</StackPane>-->
20 20
 
21
-<VBox fx:id="vista2" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="AccountController">
21
+<VBox fx:id="vista2" prefWidth="420.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="AccountController">
22 22
     <children>
23 23
         <JFXTabPane fx:id="tabPane" minHeight="50.0" prefHeight="40.0" prefWidth="466.0">
24 24
             <tabs>
@@ -72,13 +72,16 @@
72 72
                 <Insets left="8.0" right="8.0" />
73 73
             </VBox.margin>
74 74
         </JFXTextArea>
75
-        <TableView fx:id="table" maxHeight="1.7976931348623157E308" prefHeight="150.0" prefWidth="466.0">
75
+        <TableView fx:id="table" maxHeight="1.7976931348623157E308" maxWidth="420.0" prefHeight="180.0" prefWidth="420.0">
76 76
             <columns>
77 77
                 <TableColumn fx:id="typCol" prefWidth="50.0" text="Type" />
78
-                <TableColumn fx:id="datCol" prefWidth="125.0" text="Date" />
79
-                <TableColumn fx:id="amtCol" prefWidth="100.0" text="Amount" />
80
-                <TableColumn fx:id="balCol" prefWidth="150.0" text="Balance" />
78
+                <TableColumn fx:id="datCol" prefWidth="100.0" text="Date" />
79
+                <TableColumn fx:id="amtCol" prefWidth="125.0" text="Amount" />
80
+                <TableColumn fx:id="balCol" prefWidth="145.0" text="Balance" />
81 81
             </columns>
82
+         <columnResizePolicy>
83
+            <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
84
+         </columnResizePolicy>
82 85
         </TableView>
83 86
     </children>
84 87
 </VBox>

+ 3
- 1
src/main/resources/window.fxml View File

@@ -1,11 +1,13 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 
3
+<?import java.lang.*?>
3 4
 <?import javafx.scene.control.*?>
4 5
 <?import javafx.scene.layout.*?>
5 6
 <?scenebuilder-stylesheet vista.css?>
6 7
 
7 8
 <!--<VBox prefHeight="200.0" prefWidth="300.0" xmlns:fx="http://javafx.com/fxml" fx:controller="MainController">-->
8
-<VBox 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" fx:controller="MainController">
9
+
10
+<VBox prefHeight="400.0" prefWidth="450.0" style="-fx-border-color: coral; -fx-border-width: 10; -fx-border-radius: 1; -fx-border-insets: 5;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="MainController">
9 11
   <children>
10 12
     <!--<Label fx:id="headerLabel" maxWidth="1.7976931348623157E308" text="Header" VBox.vgrow="NEVER" />-->
11 13
     <StackPane fx:id="vistaHolder" VBox.vgrow="ALWAYS" />

+ 4
- 0
src/main/resources/zcb.css View File

@@ -8,4 +8,8 @@
8 8
 
9 9
 .table-view .column-header {
10 10
     -fx-background-color: lightgray;
11
+}
12
+
13
+.table-view .column-header .label .text {
14
+    -fx-font-family: Futura;
11 15
 }