Geertjan's Blog

  • October 14, 2008

World's Simplest NetBeans Node Implementation

Geertjan Wielenga
Product Manager
While looking into some small corners of the Nodes API, I realized that this is probably the simplest Nodes implementation. It is perfect for demos and presentations and trainings, etc. Anyone can code this and it is easy to explain what's going on:
class SystemPropertyNode extends Children.Keys {
protected void addNotify() {
Properties props = System.getProperties();
protected Node[] createNodes(String key) {
return new Node[]{new PropNode(key)};
private class PropNode extends AbstractNode {
private PropNode(String key) {
super(Children.LEAF, Lookups.fixed());

Once you've got that, you need this in your view component (which could be a TopComponent or a JFrame):

ExplorerManager.setRootContext(new AbstractNode(new SystemPropertyNode()));

In addition, you'd need to implement ExplorerManager.Provider and add an explorer view. But most of that part can be done via the ui in the IDE. Short, simple, nice demo of Nodes API, ending with you swapping different explorer views around to show that the model is disconnected from the view.

Update 07/23/14: Go here for an updated implementation of the above together with a TopComponent that contains it.

Join the discussion

Comments ( 2 )
  • guest Monday, April 12, 2010


    Our application is ported on netbeans platform. We are showing node hierarchy using fie system. Right now we don't want to use the file system api. We want to show it from the database.

    Please let me know any ideas/ suggestion on this topic.

    Any help would be greatly appreciated.

  • Geertjan Wielenga Monday, April 12, 2010

    Drop me an e-mail at geertjan.wielenga@sun.com and I will give you some good advice about this.

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