Geertjan's Blog

  • February 1, 2007

Sudden Understanding of the NetBeans Nodes API

Geertjan Wielenga
Product Manager
Today I was making another attempt to 'finally' come to terms with the NetBeans Nodes API, when I realized something interesting. Before revealing what it was, did you know that the most tutorialized NetBeans API is the Nodes API? The best example that I have found on the Nodes API is in Visual Library 2.0 Tutorial (Part 1). Part way down in that tutorial, in order to set up the scene for the material to be covered, you find some very simple, short, and succinct classes for adding nodes to a component palette. They're just nodes, after all, so you could add them to an explorer window instead, as described in NetBeans Nodes, Explorer Manager, and Component Palette Tutorial.

However, when you start really playing with the simple example in the abovementioned Visual Library tutorial, you suddenly realize something interesting -- each node in the hierarchy is (normally) represented by three classes:

  • A simple bean class, with getters and setters for properties, such as a 'name' and an 'ímage'.

  • A Node class (such as AbstractNode) for presenting the bean properties in the user interface, such as in an explorer window or component palette, via setDisplayName, and so on.

  • A class (such as Children.Keys) for connecting the above two classes together.

Hmmm.... three classes... one is kind of like... a model, the other one is a bit like... a view... and then... the final one is kind of like... a controller... Hmmm. Hey, wait a minute... it's coming to me now... doesn't that kind of sound like... the MVC pattern..?

Interesting, right? Take a look at your Nodes API implementations, or at samples described in the NetBeans Modules and Rich-Client Applications Learning Trail. You'll be surprised to see how much better you understand the Nodes API once you connect it to the MVC pattern.

Join the discussion

Comments ( 3 )
  • WilliamChen Thursday, February 1, 2007
    Yeah, that's a great metaphor!
    I think MVC is the most used pattern in Java.
  • guest Monday, June 4, 2012


    I am very new to the Netbeans platform and I have a question on the Nodes / Explorer APIs I have not been able to find the answer to.

    I would like to know how to make the ExplorerManager show more than one root context. For example, in Netbeans, in the projects tab all the opened projects appear as root nodes. All the tutorials I have done all only show how to make a single root node for the ExplorerManager :(

    Help please.


  • Geertjan Monday, June 4, 2012
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.