Here's a handy NetBeans API sample, useful for NetBeans plugin developers, as well as anyone working with node hierarchies on the NetBeans Platform:
When you check out the repository above and run the module into NetBeans IDE... and you then create a Java SE application, for example this:
...and you then go to the Project Properties dialog of the project, you will see usage of the ProjectCustomizer.CompositeCategoryProvider class, a simple panel with a checkbox:
When you click "Show my node" and then OK, you will see you have a new node created in your node hierarchy, thanks to an implementation of the NodeFactory class:
When you go back to the Project Properties dialog and uncheck the checkbox, and you then click OK, you will find that the "Special" node is removed.
In the ProjectCustomizer, a project preference is set to a key/value combination, to which the NodeFactory is listening for changes. When a change is detected, the Node hierarchy recreates itself with/without the special Node.
The above scenario is a bit tricky and can be useful in many situations, such as when you're extending NetBeans IDE with a plugin for some technology that needs to be configured per project, after which the project logical view needs to be updated with data relating to the configured technology.
Thanks to Peter Nabbefeld for requesting code for this scenario and to Neil C. Smith for making an important suggestion relating to the ChangeListener of the NodeList.