Doc Contributor: Silveira Neto. This tutorial was first published in my blog.
Create a new project clicking in File → New Project.
![]() |
In Categories select Netbeans Module and in Projects select Module.
![]() |
Click in Next.
In the next screen you can choose your module name, like HelloYou. Leave the rest with the default values.
![]() |
Now you have to set up the package base name, something like org.yourorg.helloyou.
![]() |
Now you have an empty module, but we need some action.
Right click in your source package and click in New → Action.
![]() |
Now we’ll fill another wizard. The first screen is about Action Type. Leave all with the default values (the Always Enabled option) and click Next.
![]() |
In the GUI Registration screen we can set where we want our action appears as an menu item. We chose Menu file and select Global Toolbar Button. In Toolbar select Build 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 ball.png your 24×24 icon should be ball24.png. Doesn’t matter where is this icon, it’ll be automatically copied to the module directory. Now click Finish.
I used an smile icon from the Pidgin Project.

After clicked in Finish your project will look like that:
![]() |
At this point we can already test our module! For doing that right click in
HelloYou (puzzle icon) and select Install/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.
![]() |
But if you click in the smile nothing happens. We have defined no action at all.
A module can have dependencies from others modules. When you try to install it, Netbeans will ask about install their modules dependencies. Is much like an Linux package system.
We can see and set up the dependencies in our module properties screen. You can right click
HelloYou and go in Properties. Another way to do the same is going in File → “HelloYou” 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 Utilities API module dependence.
![]() |
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.
![]() |
Select the module Dialogs API and click OK. Now our module have two dependencies: Utilities API and Dialogs API.
![]() |
Now for the first time, let’s right some code.
In HelloAction.java file there’s a class HelloAction that extends CallableSystemAction (an abstract class).
In the method performAction() there’s nothing but:
//TODO implement action body
We will rewrite the performAction method:
public void performAction() {
String msg = "Hello Netbeans World!";
int msgType = NotifyDescriptor.INFORMATION_MESSAGE;
NotifyDescriptor d = new NotifyDescriptor.Message(msg, msgType);
DialogDisplayer.getDefault().notify(d);
}
You will see some warnings (cannot find symbol). Just fix the imports (Ctrl+Shift+I). To test your module, do it again:
HelloYou → 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 user using NotifyDescriptor.InputLine. Will create an input line dialog, get the user name (if he clicks in Ok) and display a message to him.
public void performAction() {
NotifyDescriptor.InputLine question;
question = new NotifyDescriptor.InputLine("Name:",
"What's your name?",
NotifyDescriptor.OK_CANCEL_OPTION,
NotifyDescriptor.QUESTION_MESSAGE);
if (DialogDisplayer.getDefault().notify(question) == NotifyDescriptor.OK_OPTION) {
String msg = "Hello "+question.getInputText()+"!";
int msgType = NotifyDescriptor.INFORMATION_MESSAGE;
NotifyDescriptor d = new NotifyDescriptor.Message(msg, msgType);
DialogDisplayer.getDefault().notify(d);
}
}
Again,
HelloYou → Install/Reload in Target Platform.
After the new Netbeans instance opens, click in our smile face.
That’s it. You made your first Netbeans plugin!
| figure.1.file.new.project.png | ![]() |
16410 bytes |
| figure.10.install.reload.in.target.platform.png | ![]() |
29514 bytes |
| figure.11.look.we.got.an.plugin.png | ![]() |
86513 bytes |
| figure.12.file.helloyou.properties.png | ![]() |
31517 bytes |
| figure.13.module.dependencies.png | ![]() |
59478 bytes |
| figure.14.add.modules.dependency.png | ![]() |
29215 bytes |
| figure.15.dialogs.api.png | ![]() |
26770 bytes |
| figure.16.dialogs.api.and.utilities.api.png | ![]() |
73828 bytes |
| figure.17.hello.netbeans.world.png | ![]() |
131369 bytes |
| figure.18.png | ![]() |
12872 bytes |
| figure.19.png | ![]() |
9545 bytes |
| figure.2.new.module.png | ![]() |
17250 bytes |
| figure.3.naming.the.modules.png | ![]() |
83382 bytes |
| figure.4.package.name.png | ![]() |
44836 bytes |
| figure.5.adding.some.action.png | ![]() |
22437 bytes |
| figure.6.filling.the.action.type.png | ![]() |
19487 bytes |
| figure.7.gui.registration.png | ![]() |
119113 bytes |
| figure.8.name.icon.and.location.png | ![]() |
106554 bytes |
| figure.9.empty.action.png | ![]() |
160949 bytes |
| puzzle.png | ![]() |
521 bytes |
| wink.png | ![]() |
873 bytes |
| wink24.png | ![]() |
1568 bytes |