The org.openide.filesystems.FileUtil.findBrother method is typically used by the Matisse GUI Builder so that if a file named "" is in the same folder as a file named "xyz.frm", the two are merged together and opened as one in the editor. Specifically, FileUtil.findBrother takes a FileObject and a file extension, which is the file extension of the "brother" file.

There are several other conceivable scenarios where this functionality might be handy, such as Wicket, which typically has "" in the same folder as "xyz.html". The latter provides the markup for the former. Below you can see my point, the Java files that have a matching HTML file (i.e., the same name) have a Wicket icon merged with their Java icon:

So, first create a new DataObject for text/x-java—and make sure it will install before the standard Java DataObject. Then, use the DataLoader to branch the DataObject, depending on whether a "brother" is found:

protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
    FileObject bro = FileUtil.findBrother(primaryFile, "html");
    if (null != bro) {
        //Return our own data object:
        return new WicketDataObject(primaryFile, this);
    //Return the standard data object:
    return new JavaDataObject(primaryFile, this);

Finally, in the Node, use org.openide.util.Utilities.mergeImages to merge a small image on top of the standard Java icon:

private static final String WICKET_ICON_BASE = 
private static final String JAVA_ICON_BASE =   
public Image getIcon(int arg0) {
    Image wicket = Utilities.loadImage(WICKET_ICON_BASE);
    Image java = Utilities.loadImage(JAVA_ICON_BASE);
    Image result = Utilities.mergeImages(java, wicket, 8, 8);
    return result;

Install the module and then Java files with HTML brothers will have our Wicket icon merged with their Java icon.


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.


« November 2015