Geertjan's Blog

  • May 24, 2005

Docking a NetBeans Module in the IDE (Part 4)

Geertjan Wielenga
Product Manager
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 Anagrams.java 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 Anagrams.java 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 project.properties 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.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.