Reputation: 161
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
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