Pass Client & ClientListener through all controllers
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user