A Potential Pitfall with the TextFormatter Class in JavaFX

Posted on Thu 07 April 2016 in JavaFX • Tagged with anchor, caret, cursor, eszett, Java, JavaFX, string conversion, text field, text formatter

A common use case for the TextFormatter class in JavaFX is a text field that should convert any lower-case character input into an upper-case character. This can be achieved easily by defining a filter for the text formatter as described here. A straightforward implementation could look like this:

private UnaryOperator …

Continue reading

The TextFormatter Class in JavaFX: How to Restrict User Input in a Text Field

Posted on Tue 05 April 2016 in JavaFX • Tagged with change listener, event, JavaFX, Richard Bair, text field, text formatter

There are a lot of code examples for restricting or modifying user input into a JavaFX text field. Most examples I have seen suggest adding a change listener to the text field's text property. Here's how you would allow only lower-case characters in your text field using the change listener …


Continue reading