In part 1 we introduced the idea of plugins. In this section, we are going to dive straight in and create a plugin. We will need to assume you have some familiarity with Java as we go along.
1. Start NetBeans
Run NetBeans. I will be using my Mac (and I have added some tooltips to my menu bar) with the dark theme so you may find some things different on your machine. The ‘what’s New’ is one of my favourite features in NetBeans and the tutorials and articles are constantly being updated with new material. Notice the file menu at the top left.
2. Create a new project
Select File-New Project and select NetBeans modules. Choose the Netbeans module. You can also see the options to create an application to use the NetBeans platform. Click on Next to continue
3. Set the project Name
Add a name for the project in the top box – choose something meaningful. Click on Next
4. Set a codebase
If you already have Java packages, you may want to use that. We will be using our Jpedal code so we will put a netbeans package in there. Whatever you type, stick to lower case (No CaPiTaLiSaTIon). Click on finish
5. Check project completed.
You should now see your project in the NetBeans projects list on the left. If you do, Congratulations – you have created your first project.
6. Add an Action
NetBeans includes a large amount of features so that you can quickly put together the skeleton for your application. So let us introduce that. Select the new NetBeans project and press your menu button. We will create an Action so highlight and select.
7. Make action always available
You can choose whether this action is always available or only sometimes. We want to make it permanently available so just accept defaults.
8. Select how user can use Action
An action can appear as a menu option, a toolbar icon and have a keyboard shortcut. You can also add it into a Category or create a new one. I recommend you see if it fits into an existing category first. All these options are setup from on this page (with minimal coding from you).
9. Link the action
Lastly we need to link the Action to a Java class which NetBeans will run when the Action is selected. This will create the Java class.
10. Review Action
You should now find NetBeans has created a new class which will be called when your Action is called.
11. Running the code
It is time to run the code for the first time. If you click on the Green Arrow on the toolbar, NetBeans will run your plugin and open a second copy of NetBeans with the plugin. You will see our new Action item on the menu. It does not do anything at the moment – that will happen in the next part…
Click here for the next article in the series.
This post is part of our “NetBeans article Index” series. In these articles, we aim to explore NetBeans in different ways, from useful hint and tips, to our how-to’s, experiences and usage of the NetBeans IDE.