org.openide.nodes.FilterNode (Part 1)

No references to FilterNode in this blog, so let's change that. Here's a great reference by Tom Wheeler:

In my example, we'll filter the children of the root node, using the code referenced above. If a node display name is set to "Tom" it will not be displayed:

import java.util.ArrayList;
import java.util.List;
import org.openide.nodes.FilterNode;
import org.openide.nodes.Node;

public class ProxyChildren extends FilterNode.Children {

    public ProxyChildren(Node owner) {

    protected Node[] createNodes(Node object) {
        List<Node> result = new ArrayList<Node>();
        for (Node node : super.createNodes(object)) {
            if (accept(node)) {
        return result.toArray(new Node[0]);

    private boolean accept(Node node) {
        if (node.getDisplayName().equals("Tom")){
            return false;
        } else {
            return true;

And here's the TopComponent constructor that constructs the filtered children above:

public DemoTopComponent() {
    Node filterNode = new FilterNode(new RootNode(), new ProxyChildren(new RootNode()));

public class RootNode extends AbstractNode {
    public RootNode() {
        super(Children.create(new DemoChildFactory(), true));

More about this can be found here:


Nodes API is too old, at least it need to update to Java 5.

Posted by hantsy on October 20, 2009 at 10:49 AM PDT #

So... you're saying that the Nodes API should let you use generics? It does. So, what are you trying to say?

Posted by Geertjan on October 20, 2009 at 07:49 PM PDT #

Ok, Thanks.
I mistakes Nodes API.
I am working on the Click Plugin for NetBeans( ), and copied a FolderBrowser panel from the Struts module. It produces some warning about the Node APIs. May be the struts module used the old api.

Posted by hantsy on October 20, 2009 at 10:22 PM PDT #

The click plugin v1.0 is available now,

Posted by hantsy on October 22, 2009 at 01:42 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« February 2015