Note: These pages are being reviewed.
Creating Node Subclasses
Nodes are useful for many things beyond just representing files. If you just need a placeholder
Node, you do not need a subclass - just instantiate an
AbstractNode - despite its name,
AbstractNode is not an abstract class. For example:
AbstractNode nue = new AbstractNode (Children.LEAF); nue.setDisplayName ("Please wait..."); nue.setIcon (Utilities.loadImage ("path/in/jar/to/image.gif")); return nue;
If you are creating Nodes, you will typically deal with one of four things
AbstractNode - create a Node which represents anything you want - you will implement all its logic, provide children, etc. Typically most logic goes in the Children object.
BeanNode - a very convenient Node subclass, which can represent any JavaBean as a Node and expose its bean properties as Property objects that can be edited on the property sheet
FilterNode - a Node subclass that proxies another Node. You can subclass this to take an existing Node (possibly representing a file on disk or in the system filesystem and keep most of its attributes, but provide different actions or display name or icons or properties
DataNode - a Node subclass specific to editing files. If you are writing a module that adds support for a new file type (such as
.svgfiles), you will write a
DataNodesubclass to give files of that type icons, display names, and possibly provide access to the file’s content
Note that if you just want to write context sensitive code, not provide your own Nodes, you may be able to do it without a dependency on the Nodes API, using Utilities.actionsGlobalContext().
Apache Migration Information
The content in this page was kindly donated by Oracle Corp. to the Apache Software Foundation.
This page was exported from http://wiki.netbeans.org/DevFaqNodeSubclass , that was last modified by NetBeans user Tboudreau on 2010-01-24T05:48:37Z.
NOTE: This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.