From bfd3c10e9ee60c4a5b70fd9fcd3eaa5e4ffba81e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Wed, 12 Mar 2025 21:34:55 +0100 Subject: [PATCH] all functionality handled --- .../main/java/client/ClientGuiController.java | 42 +++++++++++++------ .../src/main/resources/client/clientVue.fxml | 5 +-- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/ChatApp/app/src/main/java/client/ClientGuiController.java b/ChatApp/app/src/main/java/client/ClientGuiController.java index d0ec7ed..bf7eb12 100644 --- a/ChatApp/app/src/main/java/client/ClientGuiController.java +++ b/ChatApp/app/src/main/java/client/ClientGuiController.java @@ -8,6 +8,7 @@ import javafx.scene.control.ButtonType; import javafx.scene.control.TextField; import javafx.scene.layout.Border; import javafx.scene.layout.BorderPane; +import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.stage.Stage; import network.protocol.packets.ServerResponsePacket; @@ -33,6 +34,9 @@ public class ClientGuiController implements ClientListener { @FXML private VBox chatList; + @FXML + private HBox chatInput; + public void setClient(Client client) { this.client = client; } @@ -43,6 +47,7 @@ public void initialize() throws SocketException { Platform.runLater(() -> { Stage stage = (Stage) vueContainer.getScene().getWindow(); stage.setOnCloseRequest(event -> { + connected = false; client.close(); }); }); @@ -55,15 +60,17 @@ public void initialize() throws SocketException { @Override public void handleConnexionError() { - Platform.runLater(() -> { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Connection"); - alert.setHeaderText("Connection failed"); - Optional res = alert.showAndWait(); - if (res.isPresent() && res.get() == ButtonType.OK) { - ((Stage) vueContainer.getScene().getWindow()).close(); - } - }); + if(connected) { + Platform.runLater(() -> { + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setTitle("Connection"); + alert.setHeaderText("Connection failed"); + Optional res = alert.showAndWait(); + if (res.isPresent() && res.get() == ButtonType.OK) { + ((Stage) vueContainer.getScene().getWindow()).close(); + } + }); + } } @Override @@ -77,7 +84,12 @@ public void initialize() throws SocketException { } @Override public void handleChatMessage(Instant time, String chatter, String content) { - + Platform.runLater(() -> { + VBox msg = new VBox(); + msg.getChildren().add(new TextField(chatter + " : " + content)); + chatList.getChildren().add(msg); +// chatList.getChildren().add() + }); } @Override @@ -100,17 +112,23 @@ public void initialize() throws SocketException { //