1010import javafx .scene .layout .AnchorPane ;
1111import javafx .scene .layout .Region ;
1212import javafx .scene .layout .VBox ;
13+ import javafx .scene .text .Font ;
14+ import javafx .scene .text .FontPosture ;
15+ import javafx .scene .text .FontWeight ;
1316import javafx .stage .Stage ;
1417import nodes .DialogBox ;
1518import util .Storage ;
1619
20+ import java .io .IOException ;
21+
1722/**
1823 * JavaFX Application used to wrap a Duke instance and provide GUI interaction
1924 * for Duke.
2025 */
2126public class Sweh extends Application {
22- private final Image userImage = new Image (this .getClass ().getResourceAsStream ("/images/DaUser.png" ));
23- private final Image dukeImage = new Image (this .getClass ().getResourceAsStream ("/images/DaDuke.png" ));
27+ private final Image userImage = new Image (this .getClass ()
28+ .getResourceAsStream ("/images/DaUser.jpg" ));
29+ private final Image dukeImage = new Image (this .getClass ()
30+ .getResourceAsStream ("/images/DaSweh.jpg" ));
31+ private final Label greetingText = new Label ("Hello, I am SWEH. "
32+ + "Your Simple Word-Executed Helper!\n "
33+ + "What shall we do today?" );
34+ private final Label storageErrorText = new Label ("A save file was found, "
35+ + "but the contents could not be read... I will start from scratch instead." );
2436 private Duke duke ;
2537 private ScrollPane scrollPane ;
2638 private VBox dialogContainer ;
@@ -51,7 +63,7 @@ public void start(Stage stage) {
5163 stage .show ();
5264
5365 //Step 2. Formatting the window to look as expected
54- stage .setTitle ("Duke " );
66+ stage .setTitle ("Sweh " );
5567 stage .setResizable (false );
5668 stage .setMinHeight (600.0 );
5769 stage .setMinWidth (400.0 );
@@ -69,6 +81,9 @@ public void start(Stage stage) {
6981 dialogContainer .setPrefHeight (Region .USE_COMPUTED_SIZE );
7082
7183 userInput .setPrefWidth (325.0 );
84+ userInput .setFont (Font .font ("Consolas" , FontWeight .BOLD ,
85+ FontPosture .REGULAR , 12 ));
86+ userInput .setStyle ("-fx-text-inner-color: saddlebrown" );
7287
7388 sendButton .setPrefWidth (55.0 );
7489
@@ -88,7 +103,20 @@ public void start(Stage stage) {
88103 //Scroll down to the end every time dialogContainer's height changes.
89104 dialogContainer .heightProperty ().addListener ((observable ) -> scrollPane .setVvalue (1.0 ));
90105
91- // more code to be added here later
106+ //Show greeting text
107+ dialogContainer .getChildren ().addAll (
108+ DialogBox .getDukeDialog (greetingText , new ImageView (dukeImage ))
109+ );
110+
111+ //Print error text if storage could not load a save file.
112+ try {
113+ storage .readTaskManager ();
114+ } catch (IOException e ) {
115+ dialogContainer .getChildren ().addAll (
116+ DialogBox .getDukeDialog (storageErrorText , new ImageView (dukeImage ))
117+ );
118+ }
119+
92120 }
93121
94122 /**
0 commit comments