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

Made amount attribute to DoubleProperty. Binded amount textfield in...

Made amount attribute to DoubleProperty. Binded amount textfield in AddExpenseController to the expense amount property
parent b8a5f7cf
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
......@@ -72,11 +72,10 @@ public class AddExpenseController {
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());
amountField.textProperty().bindBidirectional(expense.amountProperty(), NumberFormat.getNumberInstance());
descriptionField.textProperty().bindBidirectional(descriptionProperty);
}
public void pressOkBtn(ActionEvent event) {
......
......@@ -97,34 +97,33 @@ public class ExpensesController {
Dialog<Expense> dialog = new Dialog<>();
dialog.initModality(Modality.APPLICATION_MODAL);
try {
// Set the Dialog's content to the loaded FXML file
dialog.getDialogPane().setContent(loader.load());
} catch (IOException e) {
e.printStackTrace();
}
// Get the controller for the loaded FXML file
AddExpenseController dialogController = loader.getController();
if (event.getSource().equals(add)) {
mode = DialogMode.ADD;
dialogTitle = "Add expense";
newExpense = new Expense(1.1, false, ExpenseCategory.FOOD, "1/1/23");
} else if (event.getSource().equals(edit)) {
} else if (event.getSource().equals(edit) && expenseTableView.getSelectionModel().getSelectedItem() != null) {
mode = DialogMode.EDIT;
dialogTitle = "Edit expense";
newExpense = expenseTableView.getSelectionModel().getSelectedItem();
dialogController.setExpense(newExpense);
} else {
return;
}
try {
// Set the Dialog's content to the loaded FXML file
dialog.getDialogPane().setContent(loader.load());
dialog.setTitle(dialogTitle);
} catch (IOException e) {
e.printStackTrace();
}
AddExpenseController dialogController = loader.getController();
dialogController.setExpense(newExpense);
// Get the controller for the loaded FXML file
dialog.setTitle(dialogTitle);
// Show the Dialog and wait for the user to close it
dialog.showAndWait();
dialog.showAndWait();
//Get the newly created expense from the dialog pane
newExpense = dialogController.getNewExpense();
......@@ -132,7 +131,7 @@ public class ExpensesController {
if (newExpense != null && mode == DialogMode.ADD) {
expenseTableView.getItems().add(newExpense);
} else {
System.out.println("expense is null");
System.out.println("expense is null or dialog mode is add");
}
expenseTableView.refresh();
}
......
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