Coder Coder - 4 months ago 29
Java Question

In NetBeans IDE 6.1 how can I get icons for my custom GUI components in the GUI editor?

While this is by no means really important, I was just wondering if the community knows how to put icons for my custom GUI components that show up in the NetBeans GUI designer.

What I did was make several Swing components. Then I use the menu options to add them to the GUI palette, but they show up with "?" icons. It would be nice if they showed up with icons similar to swing components such as

, especially for components which are subclassed from Swing components.


You'll need to create a BeanInfo file for your components. Locate your component in the Projects window. Right click on it and choose BeanInfo Editor. Confirm that you want to create a BeanInfo. Click on the Designer tab. Choose the BeanInfo element at the top of the tree. In the property panel there are properties for color and mono icons at 16x6 and 32x32. Set these to paths to png or gif files. These are resolves as resources, so they need to be within your source tree. I generally add a "resource" package inside the package that holds my component and put the images there.

Then, from Tools > Palette > Swing/AWT Components and add the components from the project.

As you can see, this a bit involved, so I only use it for components I know I will reuse.