NetBeans Modules for Dummies (Part 5)

Now that I can create a NetBeans Module -- albeit a very simple one -- I'd like to be able to transform an existing J2SE application into a NetBeans Module. What would I have to do to make this possible? Here's a short list:

  1. Specify the changes that you want to make to the filesystem. Do you want to access the module from a menu item? A toolbar button? Or some other way? Create a layer.xml file for this purpose.
  2. Create an Action class that extends CallableSystemAction. What's very important is the performAction method, which provides the entry point to the module.
  3. Make sure that the IDE interprets the application as a module. To do this, add module entries to the manifest.mf file.
  4. Modify the application so that it works as a module. Many things to be considered here -- the more complex the application, the more intricate the considerations. Sandip Chitale has given me the following tips:

    • You should not set the "defaultCloseOperation" property of a Frame to "EXIT_ON_CLOSE". Although this works for simple applications with one frame, you do not want the whole NetBeans JVM to exit when the user closes the Frame. Therefore, change the property to "DISPOSE_ON_CLOSE" instead.
    • You should not hook the low level event MouseClicked to perform an action. Instead, you should hook the abstract event ActionPerformed. That is because you want your code to be invoked not only when the user does a mouse click but also when the user presses the spacebar or return key from the keyboard. (This comment not necessarily related to modules specifically, but useful comment nonetheless!)

  5. Generate the XML file that describes the module, as well as some related files (for update tracking purposes). Use the cluster harness or your own Ant script for this. Refer to the previous blog entry for details on the Ant script as well as on the properties that need to be set if you use a non-standard nbantext.jar file.
  6. Finally, generate the NBM itself. The method is the same as above -- use the cluster harness or your own Ant script. Refer to the previous blog entry for details on the Ant script as well as on the properties that need to be set if you use a non-standard nbantext.jar file.
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

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.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
24
25
26
27
28
29
30
   
       
Today