This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 177634

Summary: TopComponent.setName() fires a PropertyChangeEvent twice
Product: platform Reporter: fabriziogiudici <fabriziogiudici>
Component: Window SystemAssignee: issues@platform <issues>
Status: NEW ---    
Severity: normal    
Priority: P4    
Version: 6.x   
Hardware: PC   
OS: Mac OS X   
Issue Type: DEFECT Exception Reporter:

Description fabriziogiudici 2009-11-25 15:09:00 UTC
TopComponent tc = new TopComponent();
tc.setName("name1");
tc.addPropertyChangeListener("name", new PropertyChangeListener()
  {
    @Override
    public void propertyChange(PropertyChangeEvent pce)
      {
        System.err.println(pce.getPropertyName() + " / " + pce.getOldValue() + " / " + pce.getNewValue());
      }
  });

tc.setName("name2");


It prints the event twice:

name / name1 / name2
name / name1 / name2


Looking at the source of TopComponent:

    public void setName(final String name) {
        String old = getName();

        if ((name != null) && (name.equals(old))) {
            return;
        }

        super.setName(name);
        firePropertyChange("name", old, name); // NOI18N

        // XXX When displayName is null, it is used the name.
        WindowManager.getDefault().topComponentDisplayNameChanged(this, name);
    }


super.setName() calls JComponent and I thing that it already fires an event. So the subsequent firePropertyChange() is probably redundant.