I have realized that the Netbeans 6.7.1 does not set the icon to a bean component when I use the BeanInfo Editor. I created a simple bean extended of a JLabel just to show up the problem. Please, follow the next steps:
1. I opened the Netbeans IDE 6.7.1 and created a new project named "IconBeanInfoTest".
2. In the "Source Packages" node I created three new packages: "file", "gui" and "lib".
3. Into the package "file" I put a gif picture file named "Sum16x16.gif".
4. Into the package "lib" I created a new class named "MyJLabel" that extends the "JLabel" class. This new class has one constructor method that just set the text of the "JLable" using the "setText(Strint text)" method.
6. Into the "gui" package I created a new "JFrame" form that was named "JFrame1".
7. Then I right clicked over the "MyJLabel" class and chose the option "BeanInfo Editor..." Then I accepted pressing "yes" on the message "BeanInfo does not exist. Do you wish to create a new BeanInfo?" After that the "MyJLabelBeanInfo" appeared on my project.
8. So I clicked on the design bottom and scrolled to the root of the tree on the BeanInfo Editor. On the properties I set the "Icon 16x16 color" property using the form and choosing the gif image that I've had put into the "file" package.
9. After that I saved the project and pressed (SHIFT+F11) to clean and build.
10. Then I drag and drop "MyLabel" bean to a form "JFrame1", but the icon of the gif image did not appear on the Inspector panel.
1. When I follow the previous steps from 1 to 10 using Netbeans 6.5.1 the problem does not exist.
2. If I do the project using Netbeans 6.5.1 and open the same project using Netbeans 6.7.1 the problem does not exist. But if I try to change some icon using BeanInfo Editor the problem appear (I cant see my new icon on the inspector panel). After I've changed unsuccessfully the icon using Netbean 6.7.1, if I close the project and open it on the Netbeans 6.5.1 the problem will be there and property "icon 16x16 color" will be saying that happened a exception "java.lang.NullPoiterException".
I have attached a zip file including the project the two projects one made using Netbeans 6.5.1 and another one including the project made by Netbeans 6.7.1.
Created attachment 91459 [details]
The projects that show the problem.
NB 6.7.* does set the icon in BeanInfo Editor. The difference is in the icon path. It seems to miss to add initial slash in the path. Thus the icon cannot be found.
In order to work around it open MyJLabelBeanInfo.java in plain editor and change line 764 from
private static String iconNameC16 = "file/Sum16x16.gif";//GEN-BEGIN:Icons
private static String iconNameC16 = "/file/Sum16x16.gif";//GEN-BEGIN:Icons
Fixed as jet-main#db84a45fe47d and jet-main#141f5d77359c. The 2nd change set allows to reset the defined icon to null value when designer changes propagate to source code.
Integrated into 'main-golden', will be available in build *200911261400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Jan Pokorsky <firstname.lastname@example.org>
Log: #177343: fixed icon path to comply with Class.getResource
Product Version: NetBeans IDE Dev (Build 201001120200)
The fix has been ported into the release68_fixes repository.