Question

I would like to know the best method of breaking up large Java Swing classes. Some of mine are quite large and I would like to begin the process of properly modularizing my code. I saw that I could add my classes to Netbeans' palette but the problem is they are not showing me a graphical representation of what it will look like when I "drop" them into the GUI designer. Some third party jar files support getting added to the palette and they provide a graphical preview of what they'll look like once run.

My question is, I don't know the proper terminology for what this "preview" is called so I'm finding it very difficult to search for. I would like some documentation or a tutorial on how to make my current classes able to be added to the palette and see what it is they will look like in the GUI designer.

Thank you!

Was it helpful?

Solution

To get an icon, you need to provide a BeanInfo for you class.

The easiest way to do this is right click on the class in the Project window and select BeanInfo editor....

You'll want to switch to the designer view to configure which properties are expert/hidden/preferred.

  • Preferred properties appear in the top most fold (Properties) of the Property window.
  • Expert properties appear in the second fold (Other Properties).
  • Hidden do not appear at all.

You can also specify whether properties are bound, constrained, etc. To set icons, choose the topmost node of the tree (BeanInfo) and you'll see properties for the icons.

To make NetBeans treat your component as a container (or not a container):

  • Switch to Source view
  • Find the line reading
    // Here you can add code for customizing the BeanDescriptor.
  • Add this line:
    beanDescriptor.setValue("isContainer", Boolean.TRUE); // Or FALSE if it's not a container
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top