Icon + loader for client

This commit is contained in:
Clément
2025-03-05 12:55:35 +01:00
parent a83104d322
commit 6d228aee55
12 changed files with 87 additions and 19 deletions

View File

@@ -46,7 +46,7 @@ application {
} else if (project.hasProperty('client')) {
mainClass = 'ChatAppClient'
} else if (project.hasProperty('serverGui')) {
mainClass = 'server.ServerGUI'
mainClass = 'server.ServerGui'
} else {
mainClass = 'client.ClientGui'
}

View File

@@ -1,28 +1,38 @@
package client;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.StackPane;
import javafx.stage.Screen;
import javafx.stage.Stage;
import java.util.Objects;
public class ClientGui extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("JavaFX with Gradle");
Label label = new Label("Hello, JavaFX!");
StackPane root = new StackPane(label);
Scene scene = new Scene(root, 640, 480);
primaryStage.setScene(scene);
primaryStage.show();
public void start(Stage stage) throws Exception {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/client/clientLoading.fxml"));
Scene scene = new Scene(loader.load(), 800, 600);
double screenWidth = Screen.getPrimary().getVisualBounds().getWidth();
double screenHeight = Screen.getPrimary().getVisualBounds().getHeight();
double xPos = screenWidth / 2 - scene.getWidth() / 2;
double yPos = screenHeight / 2 - scene.getHeight() / 2;
scene.getStylesheets().add(getClass().getResource("clientStyle.css").toExternalForm());
stage.getIcons().add(new Image(Objects.requireNonNull(getClass().getResourceAsStream("/liscord.png"))));
stage.setTitle("Liscord");
stage.setScene(scene);
stage.setX(xPos);
stage.setY(yPos);
stage.show();
}
}

View File

@@ -0,0 +1,6 @@
package client;
import javafx.fxml.FXML;
public class ClientGuiController {
}

View File

@@ -0,0 +1,19 @@
package client;
import javafx.animation.RotateTransition;
import javafx.fxml.FXML;
import javafx.scene.shape.Arc;
import javafx.util.Duration;
public class ClientLoading {
@FXML
private Arc spinnerArc;
public void initialize() {
// Création de l'animation de rotation
RotateTransition rotate = new RotateTransition(Duration.seconds(1), spinnerArc);
rotate.setByAngle(360);
rotate.setCycleCount(RotateTransition.INDEFINITE);
rotate.play();
}
}

View File

@@ -10,7 +10,7 @@ import javafx.stage.Screen;
import java.io.IOException;
import java.util.Objects;
public class ServerGUI extends Application {
public class ServerGui extends Application {
@Override
public void start(Stage stage) throws IOException {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/server/serverVue.fxml"));
@@ -22,9 +22,9 @@ public class ServerGUI extends Application {
double xPos = screenWidth / 2 - scene.getWidth() / 2;
double yPos = screenHeight / 2 - scene.getHeight() / 2;
scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
scene.getStylesheets().add(getClass().getResource("serverStyle.css").toExternalForm());
stage.getIcons().add(new Image(Objects.requireNonNull(getClass().getResourceAsStream("/liscord.png"))));
stage.setTitle("Server");
stage.setTitle("Liscord Server");
stage.setScene(scene);
stage.setX(xPos);
stage.setY(yPos);

View File

@@ -8,7 +8,7 @@ import network.IPAddressFinder;
import java.net.SocketException;
import java.net.UnknownHostException;
public class ServerGUIController {
public class ServerGuiController {
@FXML
private Label IPAddress;
@@ -18,7 +18,7 @@ public class ServerGUIController {
private Server server;
@FXML
public void initialize() throws UnknownHostException {
public void initialize() {
IPAddress.setText("IP Address: " + IPAddressFinder.findIPAddress());
}

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.shape.Arc?>
<?import javafx.scene.control.Label?>
<StackPane xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml"
fx:controller="client.ClientLoading" style="-fx-background-color: lightgrey;">
<Arc fx:id="spinnerArc" centerX="50" centerY="50" radiusX="30" radiusY="30"
startAngle="30" length="330" fill="transparent" stroke="blue" strokeWidth="5"
/>
</StackPane>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.geometry.Insets?>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="client.ClientGuiController"
prefHeight="400.0" prefWidth="600.0">
<HBox>
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
</padding>
</HBox>
</AnchorPane>

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

View File

@@ -4,7 +4,7 @@
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<VBox alignment="CENTER" spacing="20.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="server.ServerGUIController">
<VBox alignment="CENTER" spacing="20.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="server.ServerGuiController">
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
</padding>