简体   繁体   English

失去焦点时会触发insertUpdate

[英]insertUpdate is fired when focus has lost

I want to add a documentListener to a textarea in initcomponents() method. 我想在initcomponents()方法initcomponents() documentListener添加到textarea

This is my code: 这是我的代码:

txtAreaNot.getDocument().addDocumentListener(new DocumentListener() {

        public void changedUpdate(DocumentEvent e) {
            // text was changed
            textAreaSituation = "changed";
        }
        public void removeUpdate(DocumentEvent e) {
            // text was deleted
            textAreaSituation = "deleted";
        }
        public void insertUpdate(DocumentEvent e) {
            // text was inserted
            textAreaSituation = "inserted";
        }
    });

Here is what i dont understand; 这是我不明白的; why insertupdate is fired everytime focus lost in textarea? 为什么每次在textarea中失去焦点时都会触发insertupdate? I dont insert or change anything on it. 我不插入或更改任何内容。

Sorry. 抱歉。 My mistake. 我的错。 I totally forgot to change the value of textAreaSituation after focusLost event triggered. 我完全忘记在触发focusLost事件后更改textAreaSituation的值。 So it outputs the same value. 因此它输出相同的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM