diff --git a/src/main/java/no/ntnu/idatt1002/demo/controller/SuggestRecipesController.java b/src/main/java/no/ntnu/idatt1002/demo/controller/SuggestRecipesController.java index b75c3666373f334706844506d0b14f8955a5667b..3cee1a098eff76e9ec9eac897b5a0c6bc6356536 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/controller/SuggestRecipesController.java +++ b/src/main/java/no/ntnu/idatt1002/demo/controller/SuggestRecipesController.java @@ -81,9 +81,6 @@ public class SuggestRecipesController implements Initializable { fridge = FXCollections.observableArrayList(ingredientsAtHand.getIngredientsAtHand().stream().map(foodItem -> foodItem.label).toList()); fridgeList.setItems(fridge.sorted()); setRecipeTiles(); - - }else if(clickedButton.get() == ButtonType.CANCEL) { - } } @@ -157,28 +154,21 @@ public class SuggestRecipesController implements Initializable { @FXML - private void goBack(ActionEvent event) throws IOException { + private void switchScene(ActionEvent event) throws IOException { FXMLLoader loader = new FXMLLoader(); - loader.setLocation(getClass().getResource("/view/MainMenuNew.fxml")); - + if (event.getSource() == showAllBtn) { + loader.setLocation(getClass().getResource("/view/AllRecipes.fxml")); + } else if (event.getSource() == goBackBtn) { + loader.setLocation(getClass().getResource("/view/MainMenuNew.fxml")); + } Parent root = loader.load(); Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); Scene scene = new Scene(root); stage.setScene(scene); + stage.setResizable(false); stage.show(); } - @FXML - private void showAllRecipes(ActionEvent event) throws IOException { - FXMLLoader loader = new FXMLLoader(); - loader.setLocation(getClass().getResource("/view/AllRecipes.fxml")); - - Parent root = loader.load(); - Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); - Scene scene = new Scene(root); - stage.setScene(scene); - stage.show(); - } @Override public void initialize(URL url, ResourceBundle resourceBundle) { diff --git a/src/main/resources/view/SuggestRecipes.fxml b/src/main/resources/view/SuggestRecipes.fxml index dde2ead520cb3b3c91143e044d666aee262da8bd..da43724504aa5e07e8d2f60bc9379030fc240e70 100644 --- a/src/main/resources/view/SuggestRecipes.fxml +++ b/src/main/resources/view/SuggestRecipes.fxml @@ -70,7 +70,7 @@ <left> <Pane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER"> <children> - <Button id="button-style" fx:id="goBackBtn" alignment="CENTER" contentDisplay="CENTER" layoutX="62.0" layoutY="24.0" mnemonicParsing="false" onAction="#goBack" styleClass="button-style" stylesheets="@../style.css" text="Go Back" textAlignment="CENTER"> + <Button id="button-style" fx:id="goBackBtn" alignment="CENTER" contentDisplay="CENTER" layoutX="62.0" layoutY="24.0" mnemonicParsing="false" onAction="#switchScene" styleClass="button-style" stylesheets="@../style.css" text="Go Back" textAlignment="CENTER"> <font> <Font size="14.0" /> </font> @@ -88,7 +88,7 @@ <right> <VBox alignment="CENTER_LEFT" prefHeight="400.0" prefWidth="405.0" BorderPane.alignment="CENTER"> <children> - <Button fx:id="showAllBtn" mnemonicParsing="false" onAction="#showAllRecipes" styleClass="button-style" stylesheets="@../style.css" text="Or show all recipes" textAlignment="CENTER"> + <Button fx:id="showAllBtn" mnemonicParsing="false" onAction="#switchScene" styleClass="button-style" stylesheets="@../style.css" text="Or show all recipes" textAlignment="CENTER"> <VBox.margin> <Insets left="80.0" /> </VBox.margin>