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

Added method that binds the textfields with an incoming expense

parent 635eb5da
No related branches found
No related tags found
10 merge requests!43Merging frontend-testing into master,!38"Made progressbar dynamic in accordance to spending. Added balance field....,!37Made the sub progress bars respond to changes in expense,!32Added input validation to add dialog boxes.,!30Redesigned scenes,!29Redesigned scenes,!28Redesigned scenes,!26Redesigned Main menu and expense/income windows,!24Merging frontend-testing with master,!23Merging frontend-testing and master
package no.ntnu.idatt1002.demo.controller;
import java.io.IOException;
import java.text.NumberFormat;
import java.util.Optional;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
......@@ -64,15 +69,27 @@ public class AddExpenseController {
return recurringBox.getValue().equals("Yes");
}
public void setExpense(Expense expense) {
this.newExpense = expense;
StringProperty dateProperty = new SimpleStringProperty(expense.getDate());
DoubleProperty amountProperty = new SimpleDoubleProperty(expense.getAmount());
StringProperty descriptionProperty = new SimpleStringProperty(expense.getDescription());
dateField.textProperty().bindBidirectional(dateProperty);
amountField.textProperty().bindBidirectional(amountProperty, NumberFormat.getNumberInstance());
descriptionField.textProperty().bindBidirectional(descriptionProperty);
}
public void pressOkBtn(ActionEvent event) {
String date = dateField.getText();
double amount = Double.parseDouble(amountField.getText());
String description = descriptionField.getText();
ExpenseCategory category = getCategory();
boolean recurring = isRecurring();
newExpense = new Expense(description, amount, recurring, category, date);
System.out.println(date + " " + amount + " " + description + " " + category + " " + recurring);
if (this.newExpense.getAmount() == 1.1) {
String date = dateField.getText();
double amount = Double.parseDouble(amountField.getText());
String description = descriptionField.getText();
ExpenseCategory category = getCategory();
boolean recurring = isRecurring();
newExpense = new Expense(description, amount, recurring, category, date);
System.out.println(date + " " + amount + " " + description + " " + category + " " + recurring);
}
final Node source = (Node) event.getSource();
((Stage) source.getScene().getWindow()).close();
......
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