Some minor adjustments that localize the problem of GUI in fxlm file itself (root not correctly set?) I moved the fxml file to a spot, where gradle expects it

This commit is contained in:
Seraina 2022-04-16 23:28:52 +02:00
parent 88f72d7612
commit 8e12e6e662
4 changed files with 94 additions and 13 deletions

View File

@ -1,6 +1,7 @@
plugins { plugins {
id 'java-library' id 'java-library'
id 'application' id 'application'
id 'org.beryx.jlink' version '2.12.0'
id 'org.openjfx.javafxplugin' version '0.0.10' id 'org.openjfx.javafxplugin' version '0.0.10'
id 'jacoco' id 'jacoco'
} }
@ -31,8 +32,8 @@ dependencies {
implementation 'org.apache.logging.log4j:log4j-api:2.17.1' implementation 'org.apache.logging.log4j:log4j-api:2.17.1'
implementation 'org.apache.logging.log4j:log4j-core:2.17.1' implementation 'org.apache.logging.log4j:log4j-core:2.17.1'
implementation 'org.openjfx:javafx-controls:18' implementation 'org.openjfx:javafx-controls:18'
implementation group: 'org.apache.commons', name: 'commons-collections4', version: '4.4' implementation 'org.apache.commons:commons-collections4:4.4'
implementation group: 'org.openjfx', name: 'javafx', version: '11', ext: 'pom' implementation 'org.openjfx:javafx:19-ea+5'
testImplementation('org.junit.jupiter:junit-jupiter:5.8.2') testImplementation('org.junit.jupiter:junit-jupiter:5.8.2')
} }

View File

@ -1,21 +1,21 @@
package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat; package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel; import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel;
import java.io.BufferedReader; import java.net.URL;
import java.io.InputStream; import java.util.Objects;
import java.io.InputStreamReader;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage; import javafx.stage.Stage;
public class ChatApp extends Application { public class ChatApp extends Application {
ClientModel clientModel; ClientModel clientModel;
private ChatController chatController; private ChatController chatController;
public ChatApp() {
super();
}
public ChatApp(ClientModel clientModel) { public ChatApp(ClientModel clientModel) {
this.clientModel = clientModel; this.clientModel = clientModel;
this.chatController = new ChatController(clientModel); this.chatController = new ChatController(clientModel);
@ -36,14 +36,25 @@ public class ChatApp extends Application {
*/ */
@Override @Override
public void start(Stage primaryStage) throws Exception { public void start(Stage primaryStage) throws Exception {
URL resource = ChatApp.class.getResource(
"splitPaneChatView.fxml");
if (resource == null) {
System.out.println("File wasnt found");
}
//ChatApp chatApp = new ChatApp(new ClientModel()); //ChatApp chatApp = new ChatApp(new ClientModel());
Parent root = FXMLLoader.load(getClass().getResource("splitPaneChatView.fxml")); try {
// TODO bin chatController.getChatPaneRoot() border to root border for rezising Parent root = FXMLLoader.load(
Scene scene = new Scene(root); Objects.requireNonNull(ChatApp.class.getResource(
"splitPaneChatView.fxml")));
// TODO bin chatController.getChatPaneRoot() border to root border for rezising
Scene scene = new Scene(root);
scene.setRoot(root);
primaryStage.setScene(scene);
} catch (Exception e) {
e.printStackTrace();
}
primaryStage.setResizable(true); primaryStage.setResizable(true);
primaryStage.setTitle("Chat"); primaryStage.setTitle("Chat");
primaryStage.setScene(scene);
primaryStage.show(); primaryStage.show();

View File

@ -51,7 +51,9 @@ public class ChatController implements Initializable {
private static final String chatToAll = Protocol.chatMsgToAll; private static final String chatToAll = Protocol.chatMsgToAll;
private static final String chatToLobby = Protocol.chatMsgToLobby; private static final String chatToLobby = Protocol.chatMsgToLobby;
public ChatController() {
super();
}
public ChatController(ClientModel client) { public ChatController(ClientModel client) {
this.client = client; this.client = client;
whisperTargetChosen = new SimpleBooleanProperty(); whisperTargetChosen = new SimpleBooleanProperty();

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<fx:root maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" type="AnchorPane" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat.ChatController">
<children>
<SplitPane fx:id ="chatPaneRoot" dividerPositions="0.5" layoutX="214.0" layoutY="92.0" orientation="VERTICAL" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
<children>
<ScrollPane layoutX="149.0" layoutY="-18.0" prefHeight="196.0" prefWidth="598.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<VBox fx:id="vBoxChatMessages" prefHeight="200.0" prefWidth="581.0" />
</content>
</ScrollPane>
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
<children>
<SplitPane dividerPositions="0.29797979797979796" layoutX="166.0" layoutY="8.0" prefHeight="195.0" prefWidth="598.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<SplitPane dividerPositions="0.5" layoutY="-3.0" orientation="VERTICAL" prefHeight="193.0" prefWidth="174.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
<children>
<Button fx:id="sendButton" layoutX="50.0" layoutY="21.0" mnemonicParsing="false" prefHeight="92.0" prefWidth="172.0" text="Send" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
<children>
<TextField fx:id="whisperTargetSelectField" layoutY="14.0" prefHeight="92.0" prefWidth="172.0" promptText="whisper..." AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
</items>
</SplitPane>
</children>
<padding>
<Insets bottom="5.0" left="5.0" top="3.0" />
</padding>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<TextArea fx:id="chatMsgField" layoutX="120.0" layoutY="-30.0" prefHeight="193.0" prefWidth="415.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
<padding>
<Insets bottom="5.0" right="5.0" />
</padding>
</AnchorPane>
</items>
</SplitPane>
</children>
</AnchorPane>
</items>
</SplitPane>
</children>
</fx:root>