prevent names longer than 16 chars
This commit is contained in:
parent
1e5383a332
commit
08b916c5c5
1 changed files with 6 additions and 0 deletions
|
@ -45,6 +45,8 @@ public class EditUsernameDialogController implements Initializable {
|
|||
private ButtonPressEvent cancelListener;
|
||||
private UserList userList;
|
||||
|
||||
private final int MAX_LENGTH = 16;
|
||||
|
||||
@FXML
|
||||
private void onConfirm() {
|
||||
setLocked(true);
|
||||
|
@ -101,6 +103,10 @@ public class EditUsernameDialogController implements Initializable {
|
|||
public void onUsernameChange(ObservableValue<? extends String> observable, String oldText, String newText) {
|
||||
setFieldError(State.VALID);
|
||||
confirmButton.setDisable(newText.isEmpty());
|
||||
if (textField.getText().length() > MAX_LENGTH) {
|
||||
String s = textField.getText().substring(0, MAX_LENGTH);
|
||||
textField.setText(s);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMode(Mode mode) {
|
||||
|
|
Loading…
Reference in a new issue