This repository has been archived on 2021-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
envoy/src/main/java/envoy/client/ui/LoginDialog.java

71 lines
1.6 KiB
Java
Raw Normal View History

package envoy.client.ui;
import java.io.IOException;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.*;
/**
* Project: <strong>envoy-client</strong><br>
* File: <strong>LoginDialog.java</strong><br>
* Created: <strong>03.04.2020</strong><br>
*
* @author Kai S. K. Engelbart
* @since Envoy Client v0.1-beta
*/
public final class LoginDialog extends Dialog<Void> {
/**
* Loads the login dialog using the FXML file {@code LoginDialog.fxml}.
*
* @throws IOException if an exception occurs during loading
* @since Envoy Client v0.1-beta
*/
public LoginDialog() throws IOException {
final var dialogPane = FXMLLoader.<DialogPane>load(getClass().getResource("LoginDialog.fxml"));
// Configure buttons
dialogPane.getButtonTypes().addAll(ButtonType.CANCEL, ButtonType.OK);
setDialogPane(dialogPane);
}
public static class Controller {
@FXML
private TextField userTextField;
@FXML
private PasswordField passwordField;
@FXML
private PasswordField repeatPasswordField;
@FXML
private Label repeatPasswordLabel;
@FXML
private CheckBox registerCheckBox;
@FXML
private void initialize() {
// Set initial cursor
Platform.runLater(userTextField::requestFocus);
}
@FXML
private void registerCheckboxChanged() {
// Make repeat password field and label visible / invisible
repeatPasswordField.setVisible(registerCheckBox.isSelected());
repeatPasswordLabel.setVisible(registerCheckBox.isSelected());
// Clear repeat password field if registration cancelled
if (!registerCheckBox.isSelected()) repeatPasswordField.clear();
}
}
}