Maxlength in TextField

3

I have a Textfield in javaFX, but I can not find the Maxlength property. In C # and QT5, I've done some apps, and it's very simple to find this property.

I've found some answers, though I'm in doubt whether I really need to do this "at hand" as the answers say.

Is this property in Textfield in JavaFX or not?

Example response for maxlength in JavaFX:

public static void addTextLimiter(final TextField tf, final int maxLength) {
tf.textProperty().addListener(new ChangeListener<String>() {
    @Override
    public void changed(final ObservableValue<? extends String> ov, final String oldValue, final String newValue) {
        if (tf.getText().length() > maxLength) {
            String s = tf.getText().substring(0, maxLength);
            tf.setText(s);
        }
     }
  });
}
    
asked by anonymous 08.06.2017 / 14:19

0 answers