Geertjan's Blog

  • May 30, 2005

Easy Extension of a Node's Functionality in NetBeans IDE 4.1

Geertjan Wielenga
Product Manager
I've found that it's really easy to extend a node's functionality. Starting with the System Properties sample (which is a module that I created and installed in the IDE's Runtime window as outlined here), it takes three easy steps to add a new menu to the parent node. Let's say, for example, that I want to create a new menu item called "My Own Action", as shown below:

To get the above menu item, I just need to do three things:

  1. Create MyOwnAction.java and subclass CallableSystemAction. Here you see an illustration that includes the new MyOwnAction.java:

  2. In AllPropsNode.java, modify getActions() to add an instance of MyOwnAction.class:

    public SystemAction[] getActions(boolean context) {
    return new SystemAction[] {

  3. If MyOwnAction.java refers to Bundle.properties, add a localizing tag to Bundle.properties:

    LBL_MyOwnAction=My Own Action

    For example, getName() in MyOwnAction.java is probably as follows:

    public String getName() {
    return NbBundle.getBundle(RefreshPropsAction.class).getString("LBL_MyOwnAction");

That's it. Now you can rebuild and reload the module. You've extended the node's functionality by adding a new menu item. It's a lot less painful than I would have thought.

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.