This tutorial lets you create a module which installs a single menu
item to the IDE's main menu bar.
- Create a module JAR and prepare a package for it as
described above.
- Create an Actions API | Callable Action
and place it in your module package.
- Edit the generated bundle file to customize the display name
of the action.
- Modify the method
performAction
in the action source
to take whatever action you like. For example, try writing:
protected void performAction () {
org.openide.TopManager.getDefault ().
setStatusText ("Test me!");
}
- Compile the action.
- Create a Modules API | XML Layer (Empty) in your module's package.
- In the Explorer, browse underneath the layer's Root Folder.
Create a package named
Menu
. Create a package underneath that
called Tools
(for example).
- Copy the action. On the folder
Tools
,
Paste | Default Instance. Choose any name, it does
not matter.
- Right-click your action inside the layer and select (for example)
Install... | between (separator) and Setup Wizard.
- Save the layer.
- Browse underneath the module and find the Layer category.
Copy the layer and Paste it under Layer.
- Save the module JAR, compile, and execute it.
- Check the Tools menu. There should be your item just before
Setup Wizard. Select it; the status bar will say Test me!.
Optional steps:
- Install a toolbar button: create a package beneath Root Folder
named
Toolbars
. Create a subpackage named (for example) View
.
Again copy the action and paste a default instance to View
. Again the
name of the instance (as prompted from the dialog) does not matter.
- Add a keyboard shortcut: create a package beneath Root Folder
named
Shortcuts
. Copy the action and paste a default instance here.
Choose the name of the instance according to the
abbreviated form of the keyboard shortcut.