Skip to content
Snippets Groups Projects
Commit 6060e55b authored by Harry Linrui XU's avatar Harry Linrui XU
Browse files

Made amount at disposable label and amount left labels dynamic

parent dc8ee9dd
No related branches found
No related tags found
1 merge request!53Button validation confirmation
......@@ -83,10 +83,12 @@ public class BudgetController extends FinanceController {
private PieChart budgetPieChart;
@FXML
private Label daysLeftLbl;
private Label disposableAmount;
BudgetRegister budgetRegister = new BudgetRegister();
@FXML
private Label amountLeft;
BudgetRegister budgetRegister;
/**
* Initializes the budget register, the observable budget list and the tableview, along with the values of the dropbox used for filtering the tableview.
......@@ -115,7 +117,7 @@ public class BudgetController extends FinanceController {
.readBudgetArchive("budgets/Archive");
}
//Refresh piecharts only if the budget is old
//Refresh pie charts only if the budget is old
if (!FileHandlingBudget.isNewBudget(
"budgets/" + FileHandlingSelectedBudget.
readSelectedBudget("budgets/SelectedBudget") + "/Budget")) {
......@@ -125,7 +127,10 @@ public class BudgetController extends FinanceController {
ioe.printStackTrace();
showErrorDialogBox(ioe.getMessage(), ioe.getMessage(), ioe.getMessage());
}
//Set calendar, disposable amount and amount left
formatDatePicker();
disposableAmount.setText(String.valueOf(general.getMaxAmount()));
amountLeft.setText(String.valueOf(general.getMaxAmount()));
}
/**
......@@ -243,6 +248,7 @@ public class BudgetController extends FinanceController {
//Updates the tableview and pie chart using the register
refreshTableView();
refreshPieChart();
refreshAmountLeft();
}
......@@ -267,6 +273,7 @@ public class BudgetController extends FinanceController {
general.deleteItemFromBudget(item.getBudgetCategory());
refreshTableView();
refreshPieChart();
refreshAmountLeft();
}
}
......@@ -279,6 +286,13 @@ public class BudgetController extends FinanceController {
this.budgetList.setAll(general.getBudgetItems());
}
/**
* Method for synching the amount left to the sum of budget items in the table view.
*/
private void refreshAmountLeft() {
amountLeft.setText(String.valueOf(general.getMaxAmount() - general.totalSum()));
}
/**
* Saves the changes made to the tableview by writing the information to a file.
*
......
......@@ -13,7 +13,6 @@ import java.io.IOException;
//close button i first menu
//remove printstackstraces
//HVIS CONTINUE I BUDGET PRESSES, SHOWCONFIRMATION
//VIKTIG_ BALANCE LABEL ER RØD PÅ GRØNN BAKGRUNN!!!
//Binde label to total balance i budget window (newBUdgetBert)
//En delete funksjon i select old budget
//Endre pakkenavn
......@@ -21,7 +20,6 @@ import java.io.IOException;
//Popup for edit og delete button
//confirmation for når returnBtn som returner til start. "Are you sure you want to go back. Changes will not be saved"
// FIKSE TRY CATCHES I ALLE METODENE!!!!!!!!!!
//tester for nye filklasser
//set all windows unresizable
//Bytte oversikt på dualList til Monthly ....
......
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.*?>
<?import javafx.scene.chart.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.Cursor?>
<?import javafx.scene.chart.PieChart?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.DatePicker?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.shape.Rectangle?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="750.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="no.ntnu.idatt1002.demo.controller.BudgetController">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="750.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="no.ntnu.idatt1002.demo.controller.BudgetController">
<children>
<ImageView fitHeight="500.0" fitWidth="750.0" pickOnBounds="true">
<image>
......@@ -48,22 +62,27 @@
<children>
<HBox alignment="CENTER" spacing="10.0" GridPane.columnIndex="1" GridPane.rowIndex="1">
<children>
<PieChart fx:id="budgetPieChart" legendSide="RIGHT" maxHeight="444.0" maxWidth="512.0" prefHeight="302.0" prefWidth="354.0" />
<PieChart fx:id="budgetPieChart" legendSide="RIGHT" maxHeight="444.0" maxWidth="512.0" prefHeight="297.0" prefWidth="330.0" />
</children>
</HBox>
<StackPane alignment="CENTER_LEFT" prefWidth="375.0" GridPane.rowIndex="2" GridPane.rowSpan="2147483647">
<children>
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#f8f8f8" height="26.0" stroke="#d9cccc" strokeLineCap="ROUND" strokeType="INSIDE" width="350.0" />
<HBox alignment="CENTER_LEFT" minHeight="15.0" prefHeight="36.0" prefWidth="345.0">
<HBox alignment="CENTER_LEFT" minHeight="15.0" prefHeight="36.0" prefWidth="345.0" spacing="10.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Overview: (used of disposal)">
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Left:">
<HBox.margin>
<Insets left="3.0" />
</HBox.margin>
<font>
<Font size="14.0" />
<Font name="Lucida Console" size="14.0" />
</font>
</Text>
<Label fx:id="amountLeft" text="Label">
<font>
<Font name="Lucida Console" size="14.0" />
</font>
</Label>
</children>
</HBox>
</children>
......@@ -137,15 +156,20 @@
</HBox>
</children>
</GridPane>
<HBox alignment="CENTER" GridPane.columnIndex="1">
<VBox alignment="CENTER" GridPane.columnIndex="1">
<children>
<Label alignment="CENTER" prefHeight="20.0" prefWidth="533.0" styleClass="font" stylesheets="@../style.css" text="Amount at disposal: 1000">
<Label alignment="CENTER" prefHeight="20.0" prefWidth="533.0" styleClass="font" stylesheets="@../style.css" text="Amount at disposal:">
<font>
<Font size="24.0" />
</font>
</Label>
<Label fx:id="disposableAmount" text="Label">
<font>
<Font size="18.0" />
<Font name="Lucida Console" size="18.0" />
</font>
</Label>
</children>
</HBox>
</VBox>
<TableView fx:id="budgetTableView" maxHeight="450.0" prefHeight="305.0" prefWidth="340.0" GridPane.rowIndex="1">
<columns>
<TableColumn fx:id="categoryCol" prefWidth="75.0" text="Category" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment