Skip to content

Commit

Permalink
Fixed issue where jar file does not work on macos and linux
Browse files Browse the repository at this point in the history
  • Loading branch information
nopehax committed Oct 1, 2022
1 parent 7067aa8 commit 7ab16d0
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 14 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.13'
id 'com.github.johnrengelman.shadow' version '5.1.0'
id 'checkstyle'
}
Expand All @@ -14,7 +13,7 @@ dependencies {
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.5.0'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.5.0'

String javaFxVersion = '11.0.2'
String javaFxVersion = '11'

implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac'
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/duke/DialogBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.paint.ImagePattern;
import javafx.scene.shape.Circle;

/**
* An example of a custom control using FXML.
Expand All @@ -24,7 +23,7 @@ public class DialogBox extends HBox {
@FXML
private Label dialog;
@FXML
private Circle displayPicture;
private ImageView displayPicture;

private DialogBox(String text, Image img) {
try {
Expand All @@ -35,9 +34,8 @@ private DialogBox(String text, Image img) {
} catch (IOException e) {
e.printStackTrace();
}

dialog.setText(text);
displayPicture.setFill(new ImagePattern(img));
displayPicture.setImage(img);
}

/**
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/duke/MainWindow.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package duke;

import java.util.Objects;

import duke.util.Ui;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
Expand All @@ -11,6 +13,8 @@
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;



/**
* Controller for MainWindow. Provides the layout for the other controls.
*/
Expand All @@ -25,8 +29,10 @@ public class MainWindow extends AnchorPane {
private Button sendButton;
private Duke duke;

private final Image userImage = new Image(this.getClass().getResourceAsStream("/images/plane.jpg"));
private final Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/doomba.jpg"));
private final Image userImage = new Image(
Objects.requireNonNull(this.getClass().getResourceAsStream("/images/plane.png")));
private final Image dukeImage = new Image(
Objects.requireNonNull(this.getClass().getResourceAsStream("/images/doomba.png")));

/**
* Sets up the GUI.
Expand Down
Binary file removed src/main/resources/images/doomba.jpg
Binary file not shown.
Binary file added src/main/resources/images/doomba.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/main/resources/images/plane.jpg
Binary file not shown.
Binary file added src/main/resources/images/plane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/images/wallpaper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/main/resources/view/DialogBox.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.shape.Circle?>

<fx:root alignment="TOP_RIGHT" maxWidth="1.7976931348623157E308" prefWidth="400.0" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/" xmlns:fx="http://javafx.com/fxml/1">
<children>
Expand All @@ -17,7 +17,7 @@
<Insets left="5.0" right="5.0" />
</padding>
<children>
<Circle fx:id="displayPicture" fill="#ffffff00" layoutX="30.0" layoutY="30.0" radius="30.0" stroke="BLACK" strokeType="INSIDE" />
<ImageView fx:id="displayPicture" fitHeight="55.0" fitWidth="55.0" layoutX="3.0" layoutY="3.0" />
</children>
</Pane>
</children>
Expand Down
5 changes: 2 additions & 3 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
</HBox>
</bottom>
<center>
<ScrollPane fx:id="scrollPane" hbarPolicy="NEVER" hvalue="1.0" prefHeight="556.0" prefWidth="450.0" vvalue="1.0" BorderPane.alignment="CENTER">
<ScrollPane fx:id="scrollPane" hbarPolicy="NEVER" hvalue="1.0" prefHeight="50.0" prefWidth="450.0" vvalue="1.0" BorderPane.alignment="CENTER">
<content>
<VBox fx:id="dialogContainer" prefHeight="557.0" prefWidth="440.0" style="-fx-background-image: url('./images/wallpaper.png
')"/>
<VBox fx:id="dialogContainer" prefHeight="557.0" prefWidth="440.0" style="-fx-background-image: url('./images/wallpaper.png')" />
</content>
</ScrollPane>
</center>
Expand Down

0 comments on commit 7ab16d0

Please sign in to comment.