How to limit a JTextArea to only accept a legal set of characters?

后端 未结 4 1768
闹比i
闹比i 2021-01-20 05:09

Anybody know if there is an easy way to limit the allowed characters for a JTextArea. I.e. similar to JTextField using MaskFormatter.

Specifically I want to limit th

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-20 05:43

    You may find the concept of Chaining Document Filters interesting. The first filter would automatically convert lower case characters to upper case (included in above link) so the user doesn't have to worry about this, then the second filter would validate all the characters (you would need to write your own).

提交回复
热议问题