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

后端 未结 4 1762
闹比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:24

    Implement a javax.swing.text.DocumentFilter to remove inappropriate characters. Set that on your favourite AbstractDocument and construct you JTextArea with that.

提交回复
热议问题