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

javax.swing.text.JTextComponent uses incorrect field value

    XMLWordPrintable

Details

    • tiger
    • x86
    • linux

    Description



      Name: skR10017 Date: 05/24/2000



      Java Beans 1.01 Specification reads about Beans properties definition:

      By default, we use design patterns to locate properties by looking for methods of the form:
      public <PropertyType> get<PropertyName>();
      public void set<PropertyName>(<PropertyType> a);

      Java Beans 1.01 Specification reads about PropertyChangeSupport class:

      public void firePropertyChange(String propertyName, Object oldValue, Object newValue)
      Report a bound property update to any registered listeners.
      No event is fired if old and new are equal and non-null.

      Parameters:
      propertyName The programmatic name of the property that was changed.
      oldValue The old value of the property.
      newValue The new value of the property.

      Class javax.swing.text.JTextComponent contains a bug.
      According to JavaBeans specification propertyName that is passed to firePropertyChange method
      should be equal to real propertyName that was changed and for which get<PropertyName>
      or set<PropertyName> method must exist.

      Here is citation from the source file:

      ------------------ src/javax/swing/text/JTextComponent.java --------------------
          /**
           * The bound property name for the focus accelerator.
           */
          public static final String FOCUS_ACCELERATOR_KEY = "focusAcceleratorKey";

          public void setFocusAccelerator(char aKey) {
              aKey = Character.toUpperCase(aKey);
              char old = focusAccelerator;
              focusAccelerator = aKey;
              firePropertyChange(FOCUS_ACCELERATOR_KEY, old, focusAccelerator);
          }
      --------------------------------------------------------------------------------

      Because string which is passed is "focusAcceleratorKey" but not "focusAccelerator"
      the listener which receives event does not assume that this event was generated for focusAccelerator property.

      BeanFire test from Swing testsuite fails due to this reason.

      This bug affects JDK1.3 for Linux(beta06) and Solaris(build 1.3.0rc3-Z)

      Suggestion fix:
      To change the value of FOCUS_ACCELERATOR_KEY from "focusAcceleratorKey" to "focusAccelerator"

      ======================================================================

      Attachments

        Activity

          People

            peterz Peter Zhelezniakov
            kotlsunw Kotl Kotl (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: