BeanNetter - NetBeans Module Generator for Swing Components
Tim Boudreau, 30 March 2006
There are a lot of Swing components out there - finding them and delivering them can be the hard part.
NetBeans contains a wonderful form editor - so what would be ideal is to deliver those components right
into "Matisse" - have them show up, ready to be dragged and dropped, on the component palette.
On this page is a tool which will take a JAR file, and from it generate a NetBeans plug-in module
(an .nbm file).
The plug-in embeds the JAR you gave it. When it's installed in a copy of the NetBeans IDE,
your JAR appears as a library that projects can use. And it adds all the JavaBeans that were found
in the JAR file (you can add/remove from this list before you generate
the plug-in) to the Component Palette, in a category you name.
You point it at the JAR file with the components, and then it asks a few questions such as the category,
author information and license information (it includes the text of a number of common open source licenses,
which you can select from a combo box on the license page - or you can enter whatever you want).
Launch the tool via Java WebStart™, or
have a look at the screen shots.
What to do with the result?
Well, if the components are open-source, the good folks at
nbextras.org would
be happy to take them. If they're commercial, there is the third-party update center built into NetBeans.org.
Use the
partners page to get in touch.
Caveats
- Test the nbm (especially if you plan to get it distributed through netbeans.org or nbextras.org!) - Start
NetBeans, go to Tools | Update Center, click the radio button for "Install Manually Downloaded Modules" and try
installing the resulting NBM. Try adding each component to a JPanel form. If you're redistributing your JavaBeans,
potentially hundreds of thousands of people may be trying your code. The easiest way to lose a potential user is
for something to be broken when they first try it.
- Build the JAR on the lowest JDK version you expect the components to be used on - Many people do still
run NetBeans on JDK 1.4, and expect to deploy on 1.4, so if possible, make sure the components work
correctly on JDK 1.4 (compile them on 1.4). In order to do drag-and-drop, NetBeans
will need to instantiate your component inside its own JVM.
It would not be nice if that broke something. Absolutely do not compile them with 1.6 - the class file format is
different and they definitely won't work for anyone not running 1.6 - unless you're really using 1.6 features.
- This is experimental software - it was written in an evening - yesterday evening, as this page is being written.
If there are bugs, send an email to Tim dot Boudreau at Sun-dot-Com and I'll try to help.
- Don't redistribute anything you don't have the right to redistribute - if you plan to share some
components with the world this way, and you are not the author or copyright owner of the code, make sure you
have the author's permission or the license permits it
- Whatever the original license of the code is, that's what should be in the license field, unless you
wrote it (or own the copyright) and are choosing to change the license
- If it doesn't have a default constructor, it's not a JavaBean and Matisse will not like
that very much - only put actual visual components, or non-visual ones that are usefully manipulated
via a just a property sheet and popup menu into the list of things to include
- Have good BeanInfos - there's an easy way to do this in the
NetBeans IDE- expand your class as shown
in the adjacent screen shot
and right click the Bean Patterns node - a tool that can generate and edit BeanInfo classes will open. Find the
properties that users of a given bean will probably want to set (for example, in a Color Chooser, the Color property),
and mark those as preferred. If there are things you know a user won't care about, mark them as not included in
the BeanInfo. By highlighting things that Matisse should make prominent in the property sheet and weeding out things
that are not likely to be interesting (such as
getToolkit() as a bean property), you can make your
components much easier to work with.