Geertjan's Blog

  • August 19, 2010

Moving a JSR-296 Application to the NetBeans Platform

Geertjan Wielenga
Product Manager
I've been in touch with Robert C. Kelsey for a while. I met him on the dev mailing list, i.e., the mailing list for NetBeans Platform developers. He is the owner and programmer behind AMSWin: "AMSWin is software specifically designed for AMSOIL dealers. It allows business owners to manage their Customers, fellow Dealers, Inventory, Orders and Other Transactions in a way that ensures a manageable and efficient operation. It provides detailed reports that give the dealer a vivid picture of the status of the business."

The application is being ported to Java and, since it's a large application that needs to be flexible (not all users need all features, etc), to the NetBeans Platform. Robert sent me the current state of his application, which is created on top of JSR-296, the Swing Application Framework:

Less than a day later, it is now mostly ported to the NetBeans Platform:

The benefits? A much cleaner architecture, with all the sources neatly organized into modules:

Currently there's still a dependency on the Swing Application Framework, because one of the modules is still using the ResourceMap from that framework, which can easily be exchanged with the NetBeans NbBundle class.

It's pretty cool that Robert's original JDialogs continue to work as before. I.e., I simply copied them into a module, tweaked a bit to remove the ResourceMaps, and then I was able to call them from my Action classes.

Two special hidden features of the current state of the application are that (1) @ConvertAsJavaBean is used to serialize each newly created instance of the "BusinessAccount" object (with the upper ChildFactory listening to a folder for new entries and repopulating its node hierarchy displayed in the OutlineView) and (2) the Actions defined in the lower window (which, of course, is defined in a different module to where the upper window is found) come from the layer, so that anyone can easily extend the list of menu items from an external plugin:

class OrderBasketBeanNode extends BeanNode {
public OrderBasketBeanNode(OrderBasket orderBasket) throws IntrospectionException {
super(orderBasket, Children.LEAF, Lookups.singleton(orderBasket));
public Action[] getActions(boolean context) {
List registeredOrderActions = Utilities.actionsForPath("OrderActions/");
Action[] actions = new Action[registeredOrderActions.size()];
for (int i = 0; i < registeredOrderActions.size(); i++) {
Action oneRegisteredOrderAction = registeredOrderActions.get(i);
actions[i] = oneRegisteredOrderAction;
return actions;

There are many other cool things about how all this is implemented. Maybe this example will be used as the porting example during the NetBeans Platform Certified Training in South Africa. It really illustrates many things about the NetBeans Platform.

Join the discussion

Comments ( 4 )
  • Stanyslas Matayo Thursday, August 19, 2010

    Dear Geertjan,

    Very interesting example, but i have one question about search functionality in your example, how to make it with OutlineView or BeanTreeView ? You don't implement it here.


  • Geertjan Wielenga Friday, August 20, 2010

    In fact, what you see above are two OutlineViews.

  • Geertjan Wielenga Friday, August 20, 2010

    And, yes, search functionality is going to be added. Will blog about that when it's done!

  • RS Tuesday, August 24, 2010

    The link for 'AMSOIL dealers' points to the link belw:


    Was that intentional?

    I had clicked that to find more info on what an AMSOIL dealer was. ( Though google helped out here :)

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.