Pass Client & ClientListener through all controllers

This commit is contained in:
Clément
2025-03-10 13:52:35 +01:00
parent 3abdc09819
commit 07272732d4
9 changed files with 154 additions and 36 deletions

View File

@@ -7,6 +7,7 @@ import javafx.scene.control.TextField;
import javafx.stage.Stage;
import client.ClientGui;
import java.io.IOException;
import java.net.InetSocketAddress;
import static utilities.FxUtilities.centerStage;
@@ -16,11 +17,14 @@ public class ClientLogin {
@FXML
private void login() throws IOException {
if(usernameField.getText().isEmpty()) {
String username = usernameField.getText();
if(username.isEmpty()) {
return;
}
var loader = new FXMLLoader(getClass().getResource("/client/clientLoading.fxml"));
Client client = new Client(new InetSocketAddress("localhost", 6665), loader.getController(), username);
loader.load();
((ClientLoading) loader.getController()).setClient(client);
Stage stage = (Stage) usernameField.getScene().getWindow();
stage.setScene(new Scene(loader.getRoot(), 800, 600));
centerStage(stage);