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 - TopComponent.setName() fires a PropertyChangeEvent twice
Summary: TopComponent.setName() fires a PropertyChangeEvent twice
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 6.x
Hardware: PC Mac OS X
: P4 normal (vote)
Assignee: issues@platform
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-25 15:09 UTC by fabriziogiudici
Modified: 2009-11-25 15:09 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.