71 lines
1.6 KiB
Java
71 lines
1.6 KiB
Java
|
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();
|
||
|
}
|
||
|
}
|
||
|
}
|