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

Generalised all methods that switch scene in Expenses

parent aca726dd
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
...@@ -50,6 +50,14 @@ public class ExpensesController { ...@@ -50,6 +50,14 @@ public class ExpensesController {
@FXML @FXML
private ComboBox<String> show; private ComboBox<String> show;
@FXML
private Button incomeBtn;
@FXML
private Button overviewBtn;
@FXML
private Button returnBtn;
@FXML @FXML
private TableColumn<Expense, Double> amountColumn; private TableColumn<Expense, Double> amountColumn;
...@@ -183,26 +191,21 @@ public class ExpensesController { ...@@ -183,26 +191,21 @@ public class ExpensesController {
FileHandling fileHandling = new FileHandling(); FileHandling fileHandling = new FileHandling();
fileHandling.writeItemRegisterToFile(expenseRegister, fileName); fileHandling.writeItemRegisterToFile(expenseRegister, fileName);
} }
@FXML
protected void switchIncome(ActionEvent event) throws IOException {
saveDataToFile("Expenses");
FXMLLoader loader = new FXMLLoader(SceneController.class.getResource("/view/Income.fxml"));
Parent root = loader.load();
Stage stage = (Stage)((Node)event.getSource()).getScene().getWindow();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
@FXML @FXML
public void switchOverview(ActionEvent event) throws IOException { public void switchScene(ActionEvent event) throws IOException {
saveDataToFile("Expenses"); FXMLLoader loader = new FXMLLoader();
FXMLLoader loader = new FXMLLoader(SceneController.class.getResource("/view/Overview.fxml")); if (event.getSource() == incomeBtn) {
loader.setLocation(SceneController.class.getResource("/view/Income.fxml"));
} else if (event.getSource() == overviewBtn) {
loader.setLocation(SceneController.class.getResource("/view/Overview.fxml"));
} else if (event.getSource() == returnBtn) {
loader.setLocation(SceneController.class.getResource("/view/FirstMenu.fxml"));
}
Parent root = loader.load(); Parent root = loader.load();
Stage stage = (Stage)((Node)event.getSource()).getScene().getWindow(); Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
Scene scene = new Scene(root); Scene scene = new Scene(root);
stage.setScene(scene); stage.setScene(scene);
stage.show(); stage.show();
} }
} }
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<top> <top>
<HBox BorderPane.alignment="CENTER"> <HBox BorderPane.alignment="CENTER">
<children> <children>
<Button mnemonicParsing="false" onAction="#switchIncome" text="Return "> <Button fx:id="returnBtn" mnemonicParsing="false" onAction="#switchScene" text="Return ">
<opaqueInsets> <opaqueInsets>
<Insets left="100.0" /> <Insets left="100.0" />
</opaqueInsets> </opaqueInsets>
...@@ -119,14 +119,14 @@ ...@@ -119,14 +119,14 @@
</VBox> </VBox>
<HBox prefHeight="100.0" prefWidth="200.0" GridPane.columnSpan="2" GridPane.rowIndex="2"> <HBox prefHeight="100.0" prefWidth="200.0" GridPane.columnSpan="2" GridPane.rowIndex="2">
<children> <children>
<Button mnemonicParsing="false" onAction="#switchOverview" text="Overview"> <Button fx:id="overviewBtn" mnemonicParsing="false" onAction="#switchScene" text="Overview">
<HBox.margin> <HBox.margin>
<Insets right="5.0" /> <Insets right="5.0" />
</HBox.margin></Button> </HBox.margin></Button>
<Button mnemonicParsing="false" onAction="#switchIncome" text="Income" /> <Button fx:id="incomeBtn" mnemonicParsing="false" onAction="#switchScene" text="Income" />
<Button disable="true" mnemonicParsing="false" text="Expenses" /> <Button disable="true" mnemonicParsing="false" text="Expenses" />
<Button disable="true" mnemonicParsing="false" text="Savings" /> <Button disable="true" mnemonicParsing="false" text="Savings" />
<Button mnemonicParsing="false" onAction="#switchOverview" text="Next"> <Button disable="true" mnemonicParsing="false" onAction="#switchScene" text="Next">
<HBox.margin> <HBox.margin>
<Insets left="170.0" /> <Insets left="170.0" />
</HBox.margin></Button> </HBox.margin></Button>
......
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