Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4897238

JFormattedTextField fires PropertyChangeEvent twice during setValue

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 5.0
    • 1.4.1, 1.4.2
    • client-libs
    • tiger
    • x86
    • linux, windows_2000



      Name: jk109818 Date: 07/28/2003


      FULL PRODUCT VERSION :
      jh@linux:~/develop/Customizing2/src/java/de/cursor/gui/mrv> java -version
      java version "1.4.1_03"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_03-b02)
      Java HotSpot(TM) Client VM (build 1.4.1_03-b02, mixed mode)


      FULL OS VERSION :
      Linux linux 2.4.20-4GB #1 Wed Jun 18 07:45:45 UTC 2003 i686 unknown unknown GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      Calling JFormattedTextField.setValue one time causes two PropertyChangeEvents to
      be fired instead of one.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See example code its very clear (I hope :-))

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The PropertyChangeEvent should be only fired once.
      ACTUAL -
      The event is fired twice.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.beans.PropertyChangeEvent;
      import java.beans.PropertyChangeListener;

      import javax.swing.JFormattedTextField;

      public class FormattedTextFieldBug
      {
          private static int counter;

          public static void main(String[] args)
          {
              JFormattedTextField f = new JFormattedTextField();
              
              final PropertyChangeListener pcl = new PropertyChangeListener()
              {
                  public void propertyChange(PropertyChangeEvent evt)
                  {
                      counter++;
                  }
              };
              
              f.addPropertyChangeListener("value", pcl);
              
              counter = 0;

              System.out.println("Counter before setValue:\t" + counter);
              f.setValue("dkjf");
              System.out.println("Counter should be [1]:\t" + counter);
              
          }
      }

      ---------- END SOURCE ----------
      (Incident Review ID: 192906)
      ======================================================================

            apikalev Andrey Pikalev
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: