Skip to content

Commit

Permalink
Merge pull request #7 from NereusWB922/branch-A-BetterGui
Browse files Browse the repository at this point in the history
Branch-A-BetterGui
  • Loading branch information
NereusWB922 authored Sep 17, 2023
2 parents 4e4e6eb + e0a4a8c commit 28a5e1e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/main/java/corgi/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

Expand All @@ -18,6 +19,11 @@ public class Main extends Application {

@Override
public void start(Stage stage) {
stage.setTitle("Corgi - The most intelligent chatbot");

Image icon = new Image(this.getClass().getResourceAsStream("/images/icon.jpg"));
stage.getIcons().add(icon);

try {
FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("/view/MainWindow.fxml"));
AnchorPane ap = fxmlLoader.load();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/corgi/ui/DialogBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void flip() {
ObservableList<Node> tmp = FXCollections.observableArrayList(this.getChildren());
Collections.reverse(tmp);
getChildren().setAll(tmp);
setAlignment(Pos.CENTER_LEFT);
setAlignment(Pos.TOP_LEFT);
}

/**
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/corgi/ui/MainWindow.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package corgi.ui;

import corgi.Corgi;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;

/**
* Controller for MainWindow. Provides the layout for the other controls.
*/
Expand Down Expand Up @@ -54,7 +56,20 @@ private void handleUserInput() {
DialogBox.getUserDialog(input, userImage),
DialogBox.getCorgiDialog(response, corgiImage)
);

String lowerCaseInput = input.toLowerCase();

if (lowerCaseInput.equals("bye")) {
Platform.runLater(() -> {
handleByeCommand();
});
}

userInput.clear();
}

private void handleByeCommand() {
Platform.exit();
}
}

Binary file added src/main/resources/images/icon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions src/main/resources/view/DialogBox.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.shape.Circle?>

<fx:root alignment="CENTER_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefWidth="400.0" spacing="10" style="-fx-padding: 10;" stylesheets="@../css/DialogBoxStyle.css" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1">
<fx:root alignment="TOP_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefWidth="400.0" spacing="10" style="-fx-padding: 10;" stylesheets="@../css/DialogBoxStyle.css" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label fx:id="dialog" minHeight="-Infinity" text="Label" />
<Circle fx:id="displayPicture" fill="DODGERBLUE" radius="52.0" stroke="WHITE" strokeType="INSIDE" strokeWidth="3.0" />
<Label fx:id="dialog" minHeight="-Infinity" text="Label">
<HBox.margin>
<Insets top="15.0" />
</HBox.margin></Label>
<Circle fx:id="displayPicture" fill="DODGERBLUE" radius="40.0" stroke="WHITE" strokeType="INSIDE" strokeWidth="3.0" />
</children>
<padding>
<Insets bottom="15.0" left="5.0" right="5.0" top="15.0" />
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>

<AnchorPane maxHeight="600.0" maxWidth="400.0" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" stylesheets="@../css/MainWindowStyle.css" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="corgi.ui.MainWindow">
<AnchorPane prefHeight="600.0" prefWidth="400.0" stylesheets="@../css/MainWindowStyle.css" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="corgi.ui.MainWindow">
<children>
<HBox layoutY="557.4000244140625" prefHeight="47.0" prefWidth="399.0" AnchorPane.bottomAnchor="-4.0">
<HBox layoutY="557.4000244140625" prefHeight="47.0" prefWidth="399.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<children>
<TextField fx:id="userInput" onAction="#handleUserInput" prefHeight="44.0" prefWidth="324.0" />
<Button fx:id="sendButton" mnemonicParsing="false" onAction="#handleUserInput" prefHeight="44.0" prefWidth="82.0" text="Send" />
<TextField fx:id="userInput" onAction="#handleUserInput" prefHeight="47.0" prefWidth="330.0" HBox.hgrow="ALWAYS" />
<Button fx:id="sendButton" mnemonicParsing="false" onAction="#handleUserInput" prefHeight="47.0" prefWidth="82.0" text="Send" HBox.hgrow="ALWAYS" />
</children>
</HBox>
<ScrollPane fx:id="scrollPane" hbarPolicy="NEVER" hvalue="1.0" prefHeight="557.0" prefWidth="400.0" stylesheets="@../css/MainWindowStyle.css" vvalue="1.0">
<ScrollPane fx:id="scrollPane" fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" hvalue="1.0" prefHeight="553.0" prefWidth="400.0" stylesheets="@../css/MainWindowStyle.css" vvalue="1.0" AnchorPane.bottomAnchor="47.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<VBox fx:id="dialogContainer" prefHeight="563.0" prefWidth="388.0" />
<VBox fx:id="dialogContainer" prefHeight="557.0" prefWidth="398.0" />
</content>
</ScrollPane>
</children>
Expand Down

0 comments on commit 28a5e1e

Please sign in to comment.