views:

93

answers:

1

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 and then i use the menu options to add them to the GUI pallete, but they show up with "?" icons. It would be nice if they showed up with icons similar to swing components such as JButtons, especially for components which are subclassed for Swing components.

Thanks!

+2  A: 

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.

Devon_C_Miller
Thanks a lot, i will give that a try.
Coder
Hey, sorry for the delay in trying this, but I was finally able to try it, and everything worked exactly as you described, except, my icons still don't show up in NetBeans 6.1 GUI editor. I tried compiling my component, and it's bean info, then re-adding them to the pallete, i tried restarting netbeans, and also refreshing the palette. So what i did was create a BeanInfo object though Netbeans as you described, then i set all 4 icons on the beanInfo object and put them in a resources package under my component. I tried adding the component, and the bean info object to the palette.thanks.
Coder