Skip to content

Commit 48d7cb7

Browse files
committed
setup
1 parent 21c51e8 commit 48d7cb7

5 files changed

Lines changed: 76 additions & 2 deletions

File tree

pom.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,36 @@
4848
</dependencies>
4949
<build>
5050
<plugins>
51+
52+
<!-- Compiler plugin: tells Maven to use Java 25 -->
53+
<plugin>
54+
<groupId>org.apache.maven.plugins</groupId>
55+
<artifactId>maven-compiler-plugin</artifactId>
56+
<version>3.11.0</version>
57+
<configuration>
58+
<source>25</source>
59+
<target>25</target>
60+
<release>25</release>
61+
</configuration>
62+
</plugin>
63+
64+
<!-- JavaFX plugin -->
5165
<plugin>
5266
<groupId>org.openjfx</groupId>
5367
<artifactId>javafx-maven-plugin</artifactId>
5468
<version>0.0.8</version>
5569
<configuration>
5670
<mainClass>com.example.HelloFX</mainClass>
5771
<options>
58-
<option>--enable-native-access=javafx.graphics</option>
72+
<option>--enable-native-access=javafx.graphics</option>
5973
</options>
6074
<launcher>javafx</launcher>
6175
<stripDebug>true</stripDebug>
6276
<noHeaderFiles>true</noHeaderFiles>
6377
<noManPages>true</noManPages>
6478
</configuration>
6579
</plugin>
80+
6681
</plugins>
6782
</build>
6883
</project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.example;
2+
3+
import javafx.fxml.FXML;
4+
import javafx.scene.control.ListView;
5+
import javafx.scene.control.TextField;
6+
7+
public class ChatController {
8+
9+
@FXML
10+
private ListView<String> messagesList;
11+
12+
@FXML
13+
private TextField inputField;
14+
15+
private final ChatModel model = new ChatModel();
16+
17+
@FXML
18+
private void onSend() {
19+
String message = inputField.getText().trim();
20+
if (!message.isEmpty()) {
21+
messagesList.getItems().add("Me: " + message);
22+
model.sendMessage(message);
23+
inputField.clear();
24+
}
25+
}
26+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.example;
2+
3+
public class ChatModel {
4+
5+
public void sendMessage(String message) {
6+
// TODO: send POST JSON to ntfy
7+
System.out.println("Sending message: " + message);
8+
}
9+
}

src/main/java/com/example/HelloFX.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class HelloFX extends Application {
1010

1111
@Override
1212
public void start(Stage stage) throws Exception {
13-
FXMLLoader fxmlLoader = new FXMLLoader(HelloFX.class.getResource("hello-view.fxml"));
13+
FXMLLoader fxmlLoader = new FXMLLoader(HelloFX.class.getResource("chat-view.fxml"));
1414
Parent root = fxmlLoader.load();
1515
Scene scene = new Scene(root, 640, 480);
1616
stage.setTitle("Hello MVC");
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import javafx.scene.layout.BorderPane?>
4+
<?import javafx.scene.control.ListView?>
5+
<?import javafx.scene.control.TextField?>
6+
<?import javafx.scene.control.Button?>
7+
<?import javafx.scene.layout.HBox?>
8+
9+
<BorderPane xmlns="http://javafx.com/javafx"
10+
xmlns:fx="http://javafx.com/fxml"
11+
fx:controller="com.example.ChatController">
12+
13+
<center>
14+
<ListView fx:id="messagesList"/>
15+
</center>
16+
17+
<bottom>
18+
<HBox spacing="8" style="-fx-padding: 10;">
19+
<TextField fx:id="inputField" HBox.hgrow="ALWAYS"/>
20+
<Button text="Send" onAction="#onSend"/>
21+
</HBox>
22+
</bottom>
23+
24+
</BorderPane>

0 commit comments

Comments
 (0)