Skip to content

Commit

Permalink
Fix bugs on importing fxml
Browse files Browse the repository at this point in the history
  • Loading branch information
asaierika committed Sep 15, 2022
1 parent 078d943 commit 814462a
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ application {
}

shadowJar {
archiveBaseName = "rabbit"
archiveBaseName = "Rabbit"
archiveClassifier = null
}

Expand Down
2 changes: 1 addition & 1 deletion data/data.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
T| |do laundry
T|X|do laundry
D| |write essay|2012-12-12-1200
E| |watch concert|2012-12-12-1200
4 changes: 3 additions & 1 deletion src/main/java/Rabbit/GUI/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ public void setRabbit(Rabbit r) {
private void handleUserInput() {
String input = userInput.getText();
String response = rabbit.getResponse(input);

if (input.equals("change")) {
Random rd = new Random();
int randomInt = rd.nextInt(6) + 1;
String rabbitNumber = "Rabbit" + randomInt + ".PNG";
String rabbitNumber = "Rabbit" + randomInt + ".png";
rabbitImage = new Image(this.getClass().getResourceAsStream("/images/" + rabbitNumber));
}

dialogContainer.getChildren().addAll(
DialogBox.getUserDialog(input, userImage),
DialogBox.getRabbitDialog(response, rabbitImage)
Expand Down
Binary file removed src/main/resources/images/DialogBox.png
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/resources/view/DIalogBox.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.HBox?>

<fx:root alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="133.0" prefWidth="600.0" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1">
<fx:root alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="133.0" prefWidth="600.0" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/11" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label fx:id="dialog" alignment="CENTER" prefHeight="117.0" prefWidth="452.0" style="-fx-background-color: d58a94; -fx-background-radius: 30;" text="Label" textAlignment="CENTER" textFill="WHITE" wrapText="true">
<padding>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="647.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="rabbit.gui.MainWindow">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="647.0" xmlns="http://javafx.com/javafx/11" xmlns:fx="http://javafx.com/fxml/1" fx:controller="rabbit.gui.MainWindow">
<children>
<TextField fx:id="userInput" layoutX="11.0" layoutY="558.0" onAction="#handleUserInput" prefHeight="34.0" prefWidth="574.0" AnchorPane.bottomAnchor="8.0" />
<Button fx:id="sendButton" layoutX="598.0" layoutY="555.0" mnemonicParsing="false" onAction="#handleUserInput" prefHeight="35.0" prefWidth="37.0" style="-fx-background-color: d58a94 d58a94; -fx-background-radius: 50;" text="" textFill="WHITE">
Expand Down

0 comments on commit 814462a

Please sign in to comment.