Prepare JavaFX integration

* Added JavaFX and FXML dependencies to pom.xml and module-info.java
* Added Startup Application
* Added ChatScene with ChatSceneController
This commit is contained in:
Kai S. K. Engelbart 2020-03-26 20:23:25 +01:00
parent 2df220f6c3
commit 5cd5d516c0
5 changed files with 105 additions and 0 deletions

10
pom.xml
View File

@ -30,6 +30,16 @@
<artifactId>envoy-common</artifactId>
<version>develop-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11.0.2</version>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<GridPane id="recipientLabel" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.ChatSceneController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<ListView id="userList" prefHeight="211.0" prefWidth="300.0" GridPane.rowIndex="2" />
<Label text="Label" />
<Button id="settingsButton" mnemonicParsing="false" text="Settings" GridPane.columnIndex="1" />
<ListView id="messageList" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Button id="postButton" mnemonicParsing="false" text="Post" GridPane.columnIndex="1" GridPane.rowIndex="2" />
</children>
</GridPane>

View File

@ -0,0 +1,30 @@
package envoy.client.ui;
import java.util.logging.Logger;
import envoy.util.EnvoyLog;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
/**
* Project: <strong>envoy-client</strong><br>
* File: <strong>ChatSceneController.java</strong><br>
* Created: <strong>26.03.2020</strong><br>
*
* @author Kai S. K. Engelbart
* @since Envoy Client v0.1-beta
*/
public class ChatSceneController {
private static final Logger logger = EnvoyLog.getLogger(ChatSceneController.class);
@FXML
public void postButtonClicked(ActionEvent e) {
logger.info("Post Button clicked.");
}
@FXML
public void settingsButtonClicked(ActionEvent e) {
logger.info("Settings Button clicked.");
}
}

View File

@ -0,0 +1,34 @@
package envoy.client.ui;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
/**
* Project: <strong>envoy-client</strong><br>
* File: <strong>Startup.java</strong><br>
* Created: <strong>26.03.2020</strong><br>
*
* @author Kai S. K. Engelbart
* @since Envoy Client v0.1-beta
*/
public final class Startup extends Application {
/**
* {@inheritDoc}
*/
@Override
public void start(Stage primaryStage) throws Exception {
var loader = new FXMLLoader(getClass().getResource("ChatScene.fxml"));
var anchorPane = loader.<GridPane>load();
var chatScene = new Scene(anchorPane);
primaryStage.setTitle("Envoy");
primaryStage.setScene(chatScene);
primaryStage.show();
}
public static void main(String[] args) { launch(args); }
}

View File

@ -14,4 +14,8 @@ module envoy {
requires transitive java.logging;
requires transitive java.naming;
requires transitive java.prefs;
requires javafx.controls;
requires javafx.fxml;
opens envoy.client.ui to javafx.graphics, javafx.fxml;
}