After the NetBeans Certified Training, I have decided to make a small plugin just to test it it works perfectly or not and it is working awesome. 😀 Netbeans have a modular architecture that permits plug and unplug functionalities easily using the Plugin Manager.
It’s also easy create new plugins using Netbeans itself. The steps which I performed while making a plugin are as follows:
Create a New Project clicking in File → New Project.
In the next screen you can choose your module name, like HelloTweeps. Leave the rest with the default values.
Then, Right click in your source package and click in New → Action.
In the GUI Registration screen, We can set where we want our action appears as an menu item. We chose Menu as file and select Global Toolbar Button. In Toolbar select Run and in Position select Profile Main Project…- HERE. Click Next.
Now we will set up the screen Name, Icon and Location. In Class Name we choose HelloAction. Display Name is how the class will appear in the menu, so we can spaces. You should select an icon in dimensions of 16×16. In the same directory you can put to an icon in 24×24. If your 16×16 icon is named smile.png your 24×24 icon should be smile24.png. Doesn’t matter where is this icon, it’ll be automatically copied to the module directory. Now click Finish.
At this point we can already test our module! For doing that right click in HelloTweeps(puzzle icon) and selectInstall/Reload in Target Platform. This will open a new instance of Netbeans with your module installed!
If everything goes alright you will see your icon in the toolbar.
A module can have dependencies from others modules. When you try to install it, Netbeans will ask about install their modules dependencies. We can see and set up the dependencies in our module properties screen. You can right click HelloTweeps and go in Properties. Another way to do the same is going in File → “HelloTweeps” Properties.
In the Project Properties screen select Libraries in the left side, Categories. There are listed the Java, Netbeans and all Module Dependencies of your module. By default you’ll see UI Utilities API and Utilities API module dependencies.
Click in the button Add (that one near the module dependencies). You’ll see the Add Module Dependency screen where are listed all Netbeans modules.
We want add an dependency for the Dialogs API. Type “dialogs” in the filter text field.
In HelloAction.java file , there’s a class HelloAction. In the method performAction() there’s nothing but:
//TODO implement action body
We will rewrite the performAction method:
To test your module, do it again: HelloTweeps → Install/Reload in Target Platform. A new instance of Netbeans will open and you’ll see our smile face button again. When you click it, Netbeans will show an dialog.
Let’s do more. Let’s talk with the Tweep using NotifyDescriptor.InputLine. Will create an input line dialog, get the user name (if he clicks in Ok) and display a message to him.
Again, HelloTweeps→ Install/Reload in Target Platform.
After the new Netbeans instance opens, click in our smile face.
That’s it. You made your Netbeans plugin! Now, I will try to build a plugin which will try to show the recent changes inside the NetBeans soon.Till then,