From 3483b35067300ace21a14bbf7c749dce799f7e22 Mon Sep 17 00:00:00 2001 From: Nathali Houshmand Date: Tue, 4 Nov 2025 13:56:31 +0100 Subject: [PATCH 01/16] Initial Commit --- src/main/java/module-info.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 71574a27..6e2c2933 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -4,4 +4,5 @@ opens com.example to javafx.fxml; exports com.example; + } \ No newline at end of file From 1002eac8e8ec8b5e6f57fc789c5d209a3605f494 Mon Sep 17 00:00:00 2001 From: Nathali Houshmand Date: Sat, 15 Nov 2025 22:21:07 +0100 Subject: [PATCH 02/16] Setup base mVC structure with App, ChatController and ChatView.fxml. Also had to fix big issue with running JavaFX on old JDK version. --- pom.xml | 50 +++++++++++-------- src/main/java/com/example/chat/App.java | 24 +++++++++ .../java/com/example/chat/ChatController.java | 32 ++++++++++++ src/main/java/com/example/chat/ChatModel.java | 21 ++++++++ src/main/java/module-info.java | 8 +-- .../resources/com/example/chat/ChatView.fxml | 28 +++++++++++ .../com/example/chat/model/ChatModelTest.java | 23 +++++++++ 7 files changed, 163 insertions(+), 23 deletions(-) create mode 100644 src/main/java/com/example/chat/App.java create mode 100644 src/main/java/com/example/chat/ChatController.java create mode 100644 src/main/java/com/example/chat/ChatModel.java create mode 100644 src/main/resources/com/example/chat/ChatView.fxml create mode 100644 src/test/resources/java/com/example/chat/model/ChatModelTest.java diff --git a/pom.xml b/pom.xml index c40f667e..b2950541 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,8 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 + http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.example @@ -9,14 +10,28 @@ 1.0-SNAPSHOT - 25 UTF-8 + 25 + 25 + win 6.0.0 3.27.6 5.20.0 - 25 + + + org.openjfx + javafx-controls + ${javafx.version} + ${javafx.platform} + + + org.openjfx + javafx-fxml + ${javafx.version} + ${javafx.platform} + org.junit.jupiter junit-jupiter @@ -35,17 +50,8 @@ ${mockito.version} test - - org.openjfx - javafx-controls - ${javafx.version} - - - org.openjfx - javafx-fxml - ${javafx.version} - + @@ -54,15 +60,19 @@ 0.0.8 com.example.HelloFX - - - - javafx - true - true - true + ${javafx.platform} + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + ${maven.compiler.release} + diff --git a/src/main/java/com/example/chat/App.java b/src/main/java/com/example/chat/App.java new file mode 100644 index 00000000..58206015 --- /dev/null +++ b/src/main/java/com/example/chat/App.java @@ -0,0 +1,24 @@ +package com.example.chat; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.stage.Stage; + +public class App extends Application { + + @Override + public void start(Stage stage) throws Exception { + FXMLLoader loader = new FXMLLoader(getClass().getResource("ChatView.fxml")); + Scene scene = new Scene(loader.load()); + stage.setTitle("JavaFX Chat"); + stage.setScene(scene); + stage.show(); + } + + public static void main(String[] args) { + launch(args); + } +} + + diff --git a/src/main/java/com/example/chat/ChatController.java b/src/main/java/com/example/chat/ChatController.java new file mode 100644 index 00000000..0f574e1d --- /dev/null +++ b/src/main/java/com/example/chat/ChatController.java @@ -0,0 +1,32 @@ +package com.example.chat; + +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.ListView; +import javafx.scene.control.TextField; + +public class ChatController { + + @FXML + private TextField messageInput; + + @FXML + private Button sendButton; + + @FXML + private ListView messageList; + + private ChatModel model; + + public void initialize() { + model = new ChatModel(messageList); + } + + @FXML + private void onSendClicked() { + String text = messageInput.getText(); + model.sendMessage(text); + messageInput.clear(); + } +} + diff --git a/src/main/java/com/example/chat/ChatModel.java b/src/main/java/com/example/chat/ChatModel.java new file mode 100644 index 00000000..f37d6e92 --- /dev/null +++ b/src/main/java/com/example/chat/ChatModel.java @@ -0,0 +1,21 @@ +package com.example.chat; + +import javafx.application.Platform; +import javafx.scene.control.ListView; + +public class ChatModel { + + private final ListView messageList; + + public ChatModel(ListView messageList) { + this.messageList = messageList; + } + + public void sendMessage(String text) { + if (text == null || text.isBlank()) return; + + // For now: only add to UI (network comes in later commits) + Platform.runLater(() -> messageList.getItems().add("You: " + text)); + } +} + diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 6e2c2933..153f3760 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -2,7 +2,9 @@ requires javafx.controls; requires javafx.fxml; - opens com.example to javafx.fxml; - exports com.example; + opens com.example.chat to javafx.fxml; + exports com.example.chat; -} \ No newline at end of file + opens com.example to javafx.graphics, javafx.fxml; + exports com.example; +} diff --git a/src/main/resources/com/example/chat/ChatView.fxml b/src/main/resources/com/example/chat/ChatView.fxml new file mode 100644 index 00000000..e8a3246b --- /dev/null +++ b/src/main/resources/com/example/chat/ChatView.fxml @@ -0,0 +1,28 @@ + + + + + + + + +
+ +
+ + + + + + + +