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 134345 - add property generates wrong code for setXx method
Summary: add property generates wrong code for setXx method
Status: RESOLVED DUPLICATE of bug 133153
Alias: None
Product: java
Classification: Unclassified
Component: Beans (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-01 20:12 UTC by andersb
Modified: 2008-05-02 15:51 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 andersb 2008-05-01 20:12:32 UTC
Generation of bounded and/or constrained properties (using "insert code -> add property ..."): Problem in the set-method: 

Example:

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

public class Borrower {

  private String name;
  public static final String PROP_NAME = "name";

  /**
   * Get the value of name
   *
   * @return the value of name
   */
  public String getName() {
    return name;
  }

  /**
   * Set the value of name
   *
   * @param name new value of name
   */
  public void setName(String name) {
    String oldName = name;   PROBLEM, should be String oldName = this.name
    this.name = name;
    propertyChangeSupport.firePropertyChange(PROP_NAME, oldName, name);
  }
  private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);

  /**
   * Add PropertyChangeListener.
   *
   * @param listener
   */
  public void addPropertyChangeListener(PropertyChangeListener listener) {
    propertyChangeSupport.addPropertyChangeListener(listener);
  }

  /**
   * Remove PropertyChangeListener.
   *
   * @param listener
   */
  public void removePropertyChangeListener(PropertyChangeListener listener) {
    propertyChangeSupport.removePropertyChangeListener(listener);
  }

}
Comment 1 Jan Pokorsky 2008-05-02 15:51:02 UTC
Thanks for the report. It was already fixed and the fix will be part of NB 6.1 patch.

*** This issue has been marked as a duplicate of 133153 ***