Skip to content

Commit

Permalink
Fix bug with backgound moving on GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
delishad21 committed Feb 16, 2024
1 parent 3d22b7f commit 51446fc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/grizzly/commands/ListTaskCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public String execute(Database db, Storage storage) throws GrizzlyException {
case "":
return db.toString();
default:
throw new GrizzlyException("Error: " + description + "is not stored in my database!");
throw new GrizzlyException("Error: " + description + " is not stored in my database!");
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/grizzly/ui/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void start(Stage stage) {

AnchorPane ap = fxmlLoader.load();
Scene scene = new Scene(ap);
String css = this.getClass().getResource("/application.css").toExternalForm();
String css = Main.class.getResource("/application.css").toExternalForm();
scene.getStylesheets().add(css);

stage.setScene(scene);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/grizzly/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.util.Duration;
Expand All @@ -24,11 +25,14 @@ public class MainWindow extends AnchorPane {
private TextField userInput;
@FXML
private Button sendButton;
@FXML
private ImageView background;

private Grizzly grizzly;

private Image userImage = new Image(this.getClass().getResourceAsStream("/images/DaUser.png"));
private Image grizzlyImage = new Image(this.getClass().getResourceAsStream("/images/Grizzly.png"));
private Image backgroundImage = new Image(this.getClass().getResourceAsStream("/images/BG.jpg"));

private String startupMessage = "Heyo im Grizzly.\nWhat can I do for you?";
private String goodbyeMessage = "While waiting for you to return, I shall munch on these cookies I have here";
Expand Down
10 changes: 7 additions & 3 deletions src/main/resources/application.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
.scroll-pane .viewport {
-fx-background-image: url("images/BG.jpg");
-fx-background-repeat: stretch;
-fx-background-position: center center;
}

#dialogContainer {
-fx-background-image: url("images/BG.jpg");
-fx-background-repeat: stretch;
-fx-background-position: center center;
-fx-background-color: transparent;
}

#dialog {
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="grizzly.ui.MainWindow">
<AnchorPane maxHeight="600.0" maxWidth="400.0" minHeight="600.0" minWidth="400.0" prefHeight="600.0" prefWidth="400.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="grizzly.ui.MainWindow">
<children>
<ImageView fx:id="background" fitHeight="600.0" fitWidth="400.0" pickOnBounds="true" preserveRatio="true" />
<TextField fx:id="userInput" layoutY="558.0" onAction="#handleUserInput" prefHeight="41.0" prefWidth="324.0" AnchorPane.bottomAnchor="1.0" />
<Button fx:id="sendButton" layoutX="324.0" layoutY="558.0" mnemonicParsing="false" onAction="#handleUserInput" prefHeight="41.0" prefWidth="76.0" text="Send" />
<ScrollPane fx:id="scrollPane" hbarPolicy="NEVER" hvalue="1.0" prefHeight="557.0" prefWidth="400.0" vvalue="1.0">
Expand Down

0 comments on commit 51446fc

Please sign in to comment.