I limit my TextField max length like that:
TextField
int charLimit = 6; TextField textField = new TextField(); UnaryOperator filter