Skip to content

Commit e0b2893

Browse files
friedrice231friedrice231
authored andcommitted
Add some css for the UI and also made sure the program quits when user inputs bye
1 parent 30c42ec commit e0b2893

File tree

8 files changed

+70
-3
lines changed

8 files changed

+70
-3
lines changed

src/main/java/pawpal/core/MainWindow.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.Objects;
44

5+
import javafx.application.Platform;
56
import javafx.fxml.FXML;
67
import javafx.scene.control.Button;
78
import javafx.scene.control.ScrollPane;
@@ -56,5 +57,8 @@ private void handleUserInput() {
5657
DialogBox.getDukeDialog(response, dukeImage)
5758
);
5859
userInput.clear();
60+
if (input.equalsIgnoreCase("bye")) {
61+
Platform.exit();
62+
}
5963
}
6064
}

src/main/java/pawpal/core/Parser.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public String parse(String input) {
3838
return processFindCommand(input);
3939
case CHEER:
4040
return processCheerCommand();
41+
case BYE:
42+
return processByeCommand();
4143
default:
4244
return Printer.getInvalidCommandMessage();
4345
}
@@ -120,4 +122,8 @@ private String processCheerCommand() {
120122
return "Error retrieving cheer message.";
121123
}
122124
}
125+
126+
private String processByeCommand() {
127+
return Printer.printBye();
128+
}
123129
}

src/main/java/pawpal/utils/Command.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
* List of accepted commands by PawPal.
55
*/
66
public enum Command {
7-
LIST, MARK, UNMARK, TODO, DEADLINE, EVENT, DELETE, FIND, CHEER, INVALID
7+
LIST, MARK, UNMARK, TODO, DEADLINE, EVENT, DELETE, FIND, CHEER, BYE, INVALID
88
}

src/main/java/pawpal/utils/Printer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,7 @@ public static String getInvalidCommandMessage() {
7373
return "Invalid command!";
7474
}
7575

76+
public static String printBye() {
77+
return "Bye! I'll miss you";
78+
}
7679
}
30.5 KB
Loading

src/main/resources/view/DialogBox.fxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
xmlns="http://javafx.com/javafx/17"
1414
xmlns:fx="http://javafx.com/fxml/1">
1515
<children>
16-
<Label fx:id="dialog" text="Label" wrapText="true" minHeight="-Infinity"/>
16+
<Label fx:id="dialog" text="Hello!" styleClass="chat-bubble"/>
1717
<ImageView fx:id="displayPicture" fitHeight="99.0" fitWidth="99.0" pickOnBounds="true" preserveRatio="true" />
1818
</children>
1919
<padding>

src/main/resources/view/MainWindow.fxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0"
1010
prefWidth="400.0" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1"
11-
fx:controller="pawpal.core.MainWindow">
11+
fx:controller="pawpal.core.MainWindow" stylesheets="@style.css">
1212
<children>
1313
<TextField fx:id="userInput" layoutY="558.0" onAction="#handleUserInput" prefHeight="41.0" prefWidth="324.0" AnchorPane.bottomAnchor="1.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="76.0" />
1414
<Button fx:id="sendButton" layoutX="324.0" layoutY="558.0" mnemonicParsing="false" onAction="#handleUserInput" prefHeight="41.0" prefWidth="76.0" text="Send" AnchorPane.bottomAnchor="1.0" AnchorPane.rightAnchor="0.0" />

src/main/resources/view/style.css

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* Set background for the entire chat window */
2+
#mainPane {
3+
-fx-background-image: url("/images/background.jpg");
4+
-fx-background-size: cover; /* Ensures it covers the whole screen */
5+
-fx-background-position: center;
6+
-fx-background-repeat: no-repeat;
7+
}
8+
9+
/* Customize the ScrollPane */
10+
#scrollPane {
11+
-fx-background-color: transparent;
12+
}
13+
14+
/* Style the text input */
15+
#userInput {
16+
-fx-background-color: #ffffff;
17+
-fx-border-color: #aaaaaa;
18+
-fx-border-radius: 5px;
19+
-fx-padding: 5px;
20+
-fx-font-size: 14px;
21+
}
22+
23+
/* Style the send button */
24+
#sendButton {
25+
-fx-background-color: #ff7f50;
26+
-fx-text-fill: white;
27+
-fx-border-radius: 5px;
28+
}
29+
30+
/* Add spacing to the chat messages */
31+
#dialogContainer {
32+
-fx-padding: 10px;
33+
-fx-spacing: 5px;
34+
}
35+
36+
/* Chat bubbles */
37+
.chat-bubble {
38+
-fx-background-color: #f0f0f0;
39+
-fx-padding: 10px;
40+
-fx-border-radius: 10px;
41+
-fx-wrap-text: true;
42+
}
43+
44+
/* User messages */
45+
#dialogContainer .chat-bubble {
46+
-fx-background-color: #d1e7fd;
47+
-fx-text-fill: black;
48+
}
49+
50+
/* Bot messages */
51+
.reply-label {
52+
-fx-background-color: #ffebcd;
53+
-fx-text-fill: black;
54+
}

0 commit comments

Comments
 (0)