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

DefaultTreeSelectionModel: getListeners() returning incorrect value.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0
    • client-libs

      NOTE: The following bug has already been filed as bug#4257555. I had to create a new bug report because the original bug report was closed as a "duplicate" which did not allow me reopen it. I am reopening this bug because it's not a duplicate of the stated one (#4257538). It has its' own implementation of the "getListeners" method and does not inherit it.

      edmund.lou@eng 1999-09-13

      --------------------------------------------------------------------------------



      The getListeners() implemented at DefaultTreeSelectionModel level doesn't return the correct value for PropertyChangeListener.

      For the following program, getListeners() always returns 0 no matter how many PropertyChangeListeners you add to the component.


      ------------------------------------ Cut Here ---------------------------------

      import javax.swing.tree.*;
      import java.beans.*;
      import java.util.*;

      public class TestGetListenersForDefaultTreeSelectionModel
      implements PropertyChangeListener{

          DefaultTreeSelectionModel aComp = new DefaultTreeSelectionModel();
          EventListener[] eventListener;

          public TestGetListenersForDefaultTreeSelectionModel() {
              eventListener = aComp.getListeners(PropertyChangeListener.class);
              System.out.println("Before adding a listener: " + eventListener.length);

              aComp.addPropertyChangeListener(this);

              eventListener = aComp.getListeners(PropertyChangeListener.class);
              System.out.println("After adding a listener: " + eventListener.length);
          }

          public void propertyChange(PropertyChangeEvent e) {}

          public static void main(String[] args) {
              new TestGetListenersForDefaultTreeSelectionModel();
          }
      }

      ----------------------------------- Cut Here ----------------------------------

      edmund.lou@eng 1999-07-27
      JFC SQE

            elousunw Edmund Lou (Inactive)
            elousunw Edmund Lou (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: