Java – jtextfield listener when modifying textfield text

I know how to add a text listener on jtextfield, trigger when the text changes, and modify the text of jtextfield during operation

It seems appropriate that I try to use addinputmethodlistener, but it doesn't seem to work I also tried textfield getDocument(). Adddocumentlistener(), but this throws a Java Lang. IllegalStateException: when I try to modify the text of textfield, I try to mutate in the notification

Solution

Documentlisteners cannot modify the underlying document of JTextComponent You are looking for documentfilter

Example

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>