package client; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.control.TextField; import javafx.stage.Stage; import java.io.IOException; import static utilities.FxUtilities.centerStage; public class ClientLogin { @FXML public TextField usernameField; /** * Sets the username and switches to the loading screen. * @throws IOException if the FXML file is not found. */ @FXML private void login() throws IOException { String username = usernameField.getText(); if(username.isEmpty()) { return; } UsernameSingleton.getInstance().setUsername(username); var loader = new FXMLLoader(getClass().getResource("/client/clientLoading.fxml")); loader.load(); Stage stage = (Stage) usernameField.getScene().getWindow(); stage.setScene(new Scene(loader.getRoot(), 800, 600)); centerStage(stage); } }