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 117701 - Property editor for double[] array only updates image if array length changes
Summary: Property editor for double[] array only updates image if array length changes
Status: RESOLVED INVALID
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-03 21:27 UTC by cayhorstmann
Modified: 2008-02-21 13:47 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Bean JAR (source code inside as well) (24.25 KB, application/octet-stream)
2007-10-03 21:28 UTC, cayhorstmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description cayhorstmann 2007-10-03 21:27:15 UTC
If a JavaBean has a double[] valued property, and a property editor is supplied, then the NetBeans design view properly
shows and invokes the property editor. But when the array values are changed without changing the length of the array,
the bean is not updated correctly.

I attach the JAR with the bean (source code inside as well). Try it out: click on the values property and edit some of
the values. The bean is not updated. Change the length, and it is updated. 

When I changed the bean code to paint the array's toString code in the bean and the editor, it became apparent that the
array was being substituted somewhere.
Comment 1 cayhorstmann 2007-10-03 21:28:20 UTC
Created attachment 50141 [details]
Bean JAR (source code inside as well)
Comment 2 Jan Stola 2008-02-21 13:47:05 UTC
The problem is not in GUI builder, but in the property editor. The value returned by the property editor should be a 
different instance than the old value, otherwise oldValue.equals(newValue) and therefore the GUI builder does not 
update the corresponding bean (ChartBean). So, the DoubleArrayEditorPanel shouldn't modify the array obtained from 
ed.getValue(), it should create a new one.

For example, you can replace

      setArray((double[]) ed.getValue());

by

      double[] temp = (double[]) ed.getValue();
      setArray(Arrays.copyOf(temp, temp.length));

in the constructor of DoubleArrayEditorPanel. And add

         editor.setValue(Arrays.copyOf(array, array.length));

after model.setValue(currentIndex, v); in the changeValue() method.