artek
artek

Reputation: 161

Javafx Text Area User Input

I need to check user input in realtime. So when the user has entered more than for example 40 characters, he will be sent to the next line. I tried to use getText method in onKeyReleased method, but when the user hold the key, it can enter more than 40 characters. Sorry, maybe the explanation is not good enough.

Upvotes: 0

Views: 483

Answers (1)

Anonymous Dude
Anonymous Dude

Reputation: 21

Maybe what you are looking is something like that:

/* [Code...] */

 @FXML
    private void initialize() {
        firstField.textProperty().addListener((observable, oldValue, newValue) -> {
            if (newValue.length() > 40)
                secondField.requestFocus();
        });
    }

/* [Code..] */

Need to do the changes on the Controller class. As Sendrick suggested on the link this.

Upvotes: 2

Related Questions