Skip to content
Snippets Groups Projects
Commit 7db22c03 authored by HSoreide's avatar HSoreide
Browse files

Make button in running MainMenu open Suggested Recipes view

parent ba95587c
No related branches found
No related tags found
2 merge requests!42Hs frontend recipes,!41Hs frontend recipes
......@@ -151,7 +151,8 @@ public class MainMenu {
private void switchScene(ActionEvent event) throws IOException {
FXMLLoader loader = new FXMLLoader();
if (event.getSource() == foodBtn) {
System.out.println("Food button pressed");
System.out.println("Food button pressed"); //TODO: HS working on recipes frontend.
loader.setLocation(getClass().getResource("/view/SuggestRecipes.fxml"));
} else if (event.getSource() == expenseBtn) {
loader.setLocation(getClass().getResource("/view/IncomeAndExpenses.fxml"));
} else if (event.getSource() == incomeBtn) {
......
package no.ntnu.idatt1002.demo.controller;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import java.io.IOException;
public class SuggestRecipesController {
@FXML
private void addToFridge(ActionEvent event) throws IOException {
FXMLLoader loader = new FXMLLoader();
System.out.printf("Time to pop up the pop-up!");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.DatePicker?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ProgressBar?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.TilePane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<AnchorPane fx:id="root" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="no.ntnu.idatt1002.demo.controller.MainMenu">
<AnchorPane fx:id="root" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="no.ntnu.idatt1002.demo.controller.MainMenu">
<children>
<ImageView fitHeight="719.0" fitWidth="1130.0" layoutY="-3.0" pickOnBounds="true" preserveRatio="true">
<image>
......@@ -189,7 +176,7 @@
</BorderPane>
<TilePane alignment="CENTER" hgap="50.0" prefHeight="215.0" prefWidth="1131.0">
<children>
<Button fx:id="foodBtn" alignment="TOP_CENTER" contentDisplay="TOP" mnemonicParsing="false" prefHeight="100.0" prefWidth="150.0" text="Food">
<Button fx:id="foodBtn" alignment="TOP_CENTER" contentDisplay="TOP" mnemonicParsing="false" onAction="#switchScene" prefHeight="100.0" prefWidth="150.0" text="Food">
<graphic>
<ImageView fitHeight="75.0" fitWidth="75.0" pickOnBounds="true" preserveRatio="true">
<image>
......
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