Docking a NetBeans Module in the IDE (Part 4)

In Docking a NetBeans Module in the IDE (Part 2), I listed the files that are necessary for docking a NetBeans Module. Now, in this blog entry, here is some actual sample code as well. This sample code turns the Anagrams sample, available in the IDE when you click Ctrl-Shift-N and go to the Samples category, into a NetBeans Module that can be docked in one of the IDE's (or the Platform's) modes. (Don't know what "docking" means and how it can make your module fit really snugly in the IDE or Platform? Click here for a little bit of background.) The structure of the module should be as illustrated below (click to enlarge):

Note that the build and dist folders in the illustration above are generated when you build the application. The netbeans folder and the .nbm file are generated when you build the module. Targets for all of these activities are provided in the build.xml referred to below.

So, here is the list of files needed, but this time with a link to a file containing the code in question:

On top of that, you need to change because the Anagrams sample wasn't made to be a dockable NetBeans Module. So, there are a few things that don't work within the context of a dockable NetBeans Module. For example, the sample extends JFrame, and it has a menubar, which are not things that you'd find in modules that are dockable. For example, look at the Projects window -- a tree hierarchy is used there. The Output window just has a big text field. So, click here to get the restructured file.

Finally, you need a build.xml file that contains the Ant scripts used for creating and loading the NetBeans module. Click here to get the build.xml file generated by the IDE for standard projects, together with the relevant Ant targets. Note that it imports nbproject/build-impl.xml, which you can get for yourself by creating a new web application from scratch. (You also need some module-specific properties in a file, so click here to get it.)

That's it. Now you have everything you need to transform the Anagrams sample into a dockable NetBeans Module. Take a look at Docking a NetBeans Module in the IDE (Part 3) for some of the possibilities.


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.


« July 2016