## Creating an Action

See Also

The New Action wizard creates a new action.

To create a new action:

1. Right-click a module project and choose New > Action.
2. In the Action Type page, you set the type:
   - Always Enabled (use CallableSystemAction). Specifies that the action will be invoked from a menu item in the menu bar, from a toolbar button in a toolbar, or from a keyboard shortcut anywhere in the IDE.
   - Conditionally Enabled (use CookieAction). Specifies the classes for which the action will be created. This is normally one of your own classes. For example, if you use the New File wizard, one of the generated classes is called `somethingDataObject`. This is the name of the cookie class that you type in the Conditionally Enabled drop-down list. However, optionally, you can also include one or more of the following, which creates the action for all classes that subclass them:
     - DataObject
     - EditCookie
     - EditorCookie
     - OpenCookie
     - Project
     - User Selects One Node.
       User May Select Multiple Nodes. Specifies the conditions under which the action will be enabled. By default, the action will only be enabled when the node for which it is created is selected. If you select User May Select Multiple Nodes, the action will also be enabled when more nodes than just the node for which it is created is selected.

   Click Next.

3. In the GUI Registration page, you have to specify how the user will be able to call the new action.
   - Category. Specifies where the action will be displayed in the Keymap section of the Options window.
   - Global Menu Item. Specifies the menu where the action will be displayed as an item. You can also specify the position within the menu, and whether you want a separator to appear before it, after it, or both.
   - Global Toolbar Button. Specifies the toolbar where the action will be displayed as a button. You can also specify the position within the toolbar.
   - Global Keyboard Shortcut. Specifies a shortcut that will invoke the action.

   Only if Conditionally Enabled (use CookieAction) is selected in the Action Type page can you set the following items:

   - File Type Context Menu Item. Specifies the file type where the action will be displayed in the pop-up menu.
   - Editor Context Menu Item. Specifies the IDE editor where the action will be displayed in the pop-up menu.

   Click Next.

4. In the Name, Icon, and Location page, you set the following:
   - Class Name. Specifies the name of the new Action class.
   - Display Name. Specifies the action's label. (Optional)
   - Icon. Specifies the icon that will accompany the action. For example, if the action will be invoked by a toolbar button, the icon specified here is displayed on the toolbar button.
   - Package. Specifies the name of the package where the class will be housed.

   Click Finish.

5. After completing the wizard, you can do the following:
   - Tweak the `layer.xml` file to change the icon or to rearrange the position of the action within the actions provided by the available modules.

See Also
  About NetBeans Platform and Module Development
  About the NetBeans Platform

Legal Notices