title: Why JTextField.setText will fire DocumentListener's removeUpdate() before changedUpdate()?
body: <p>This is my code:</p>
  
  <pre><code>import javax.swing.*;
  import javax.swing.event.DocumentEvent;
  import javax.swing.event.DocumentListener;
  import javax.swing.text.Document;
  import java.awt.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  public class Frame extends JFrame {
  
      private JTextField txt1 = new JTextField(10);
      private JTextField txt2 = new JTextField(10);
      private JButton btn = new JButton("Set Text");
  
      public Frame() {
          super("Latihan");
          setLayout(new FlowLayout());
          btn.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                  txt1.setText("TEST"); txt2.setText("TEST2");
              }
          });
  
          txt1.getDocument().addDocumentListener(new TheDocumentListener("txt1"));
          txt2.getDocument().addDocumentListener(new TheDocumentListener("txt2"));
  
          add(txt1);
          add(txt2);
          add(btn);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          pack();
          setVisible(true);
      }
  
      public static void main (String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
              @Override
              public void run() {
                  new Frame();
              }
          });
      }
  }
  
  class TheDocumentListener implements DocumentListener {
  
      private String source;
  
      public TheDocumentListener(String source) {
          this.source = source;
      }
      @Override
      public void insertUpdate(DocumentEvent e) {
          System.out.println("insertUpdate from " + source);
      }
  
      @Override
      public void removeUpdate(DocumentEvent e) {
          System.out.println("removeUpdate from " + source);
      }
  
      @Override
      public void changedUpdate(DocumentEvent e) {
          System.out.println("changedUpdate from " + source);
      }
  }
  </code></pre>
  
  <p>When I click on the JButton for the first time, only <code>insertUpdate()</code> will be called:</p>
  
  <pre><code>insertUpdate from txt1
  insertUpdate from txt2
  </code></pre>
  
  <p>But if I click the button again, <code>removeUpdate()</code> will be called before <code>insertUpdate()</code>:</p>
  
  <pre><code>removeUpdate from txt1
  insertUpdate from txt1
  removeUpdate from txt2
  insertUpdate from txt2
  </code></pre>
  
  <p>Is this expected behaviour or something wrong in my code?  </p>
  
  <p>Can I make <code>insertUpdate</code> the only method that was being called when performing <code>JTextField.setText</code>?  I want to make sure <code>removeUpdate</code> is being called only when user delete text in the text field.  How to do that?</p>