Skip to content
Snippets Groups Projects
Commit d82555d2 authored by Anders Emil Bergan's avatar Anders Emil Bergan
Browse files

switched to SceneBuilder setup for further development.

parent 70d9a1f4
No related branches found
No related tags found
1 merge request!6Merging the frontend baseline to get up to date with the progress
Pipeline #202042 passed
package no.ntnu.idatt1002.demo;
import no.ntnu.idatt1002.demo.view.MyWindow;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Parent;
import javafx.scene.Scene;
/**
* Use this class to start the application
* @author nilstes
*/
public class MyApp {
import java.util.Objects;
static StartMenu menu = new StartMenu();
public class MyApp extends Application {
/**
* Main method for my application
*/
public static void main(String[] args) throws Exception {
menu.start();
}
}
@Override
public void start(Stage stage) {
try {
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("FirstMenu.fxml")));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
\ No newline at end of file
package no.ntnu.idatt1002.demo;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.scene.text.*;
import javafx.stage.Stage;
import java.io.FileInputStream;
import java.io.IOException;
public class StartMenu extends Application{
@Override
public void start(Stage primaryStage) throws IOException {
primaryStage.setTitle("BudgetBuddy");
ImageView bck = new ImageView(new Image(new FileInputStream("src/main/resources/Defaults/budgetbuddycover.jpeg")));
bck.setPreserveRatio(true);
bck.setFitWidth(750);
StackPane pane = new StackPane();
HBox buttons = new HBox();
VBox layout = new VBox();
Button opt1 = new Button("Start New Budget");
Button opt2 = new Button("Continue Ongoing Budget");
opt1.setPadding(new Insets(20,100,20,100));
opt2.setPadding(new Insets(20,100,20,100));
buttons.getChildren().addAll(opt1, opt2);
buttons.setAlignment(Pos.CENTER);
buttons.setSpacing(75);
Text text = new Text();
String textContent = "BudgetBuddy";
text.setText(textContent);
text.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 60));
layout.getChildren().addAll(text, buttons);
layout.setAlignment(Pos.CENTER);
layout.setSpacing(100);
pane.getChildren().addAll(bck, layout);
Scene scene = new Scene(pane);
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.show();
}
public void start() {
start();
}
}
package no.ntnu.idatt1002.demo;
import java.io.IOException;
import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class sceneController {
private Stage stage;
private Scene scene;
private Parent root;
public void switchStartMenu(ActionEvent event) throws IOException {
root = FXMLLoader.load(getClass().getResource("view/StartMenu.fxml"));
stage = (Stage)((Node)event.getSource()).getScene().getWindow();
scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
public void switchNewBudget(ActionEvent event) throws IOException {
root = FXMLLoader.load(getClass().getResource("view/NewBudget.fxml"));
stage = (Stage)((Node)event.getSource()).getScene().getWindow();
scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="no.ntnu.idatt1002.demo.view.NewBudget"
prefHeight="400.0" prefWidth="600.0">
</AnchorPane>
package no.ntnu.idatt1002.demo.view;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
import java.io.FileInputStream;
import java.io.IOException;
public class NewBudget {
private static StackPane root;
public static Pane getRoot() throws IOException {
TextArea income = new TextArea();
TextArea income2 = new TextArea();
income.setMaxSize(200, 20);
income2.setMaxSize(200, 20);
VBox inputs = new VBox();
inputs.getChildren().addAll(income, income2);
inputs.setAlignment(Pos.CENTER);
inputs.setSpacing(100);
return root;
}
}
.label {
-fx-font-size: 60px;
}
.outline.label .text {
-fx-fill: white;
-fx-stroke: black;
-fx-stroke-width: 2px;
}
\ No newline at end of file
src/main/resources/Defaults/backgroundMini.jpg

203 KiB

<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="no.ntnu.idatt1002.demo.sceneController">
<children>
<ImageView fitHeight="412.0" fitWidth="614.0" layoutX="-7.0" layoutY="-6.0" pickOnBounds="true" smooth="false">
<image>
<Image url="@../Defaults/backgroundMini.jpg" />
</image>
</ImageView>
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="73.0" layoutY="113.0" lineSpacing="1.0" text="Welcome to BudgetBuddy!" textAlignment="CENTER" textOverrun="LEADING_ELLIPSIS" wrapText="true">
<font>
<Font name="Verdana" size="34.0" />
</font>
</Label>
<Label ellipsisString="" layoutX="147.0" layoutY="171.0" lineSpacing="1.0" text="Please choose one of the options:" textAlignment="CENTER">
<font>
<Font name="Verdana" size="18.0" />
</font>
</Label>
<Button layoutX="69.0" layoutY="212.0" mnemonicParsing="false" text="New Budget">
<font>
<Font size="24.0" />
</font>
</Button>
<Button layoutX="380.0" layoutY="212.0" mnemonicParsing="false" text="Old Budget">
<font>
<Font size="24.0" />
</font>
</Button>
</children>
</AnchorPane>
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