JDK-4271266 : DefaultTreeSelectionModel: getListeners() returning incorrect value.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 1999-09-13
  • Updated: 1999-10-06
  • Resolved: 1999-10-06
Related Reports
Duplicate :  
Description
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

Comments
EVALUATION Closing as a duplicate. edmund.lou@eng 1999-10-06
06-10-1999