Skip to content
Advertisement

JavaFX 2.2 TextField maxlength

I am working on a JavaFX 2.2 project and I have a problem using the TextField control. I want to limit the number of characters that a user will be able to enter into each TextField. However I can’t find a property or something like maxlength. The same problem existed in Swing and was solved this way. How to solve it for JavaFX 2.2?

Advertisement

Answer

This is a better way to do the job on a generic text field:

JavaScript

Works perfectly, except for that Undo bug.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement