How do I add an action to a project node’s popup menu of my own project type?

Apache NetBeans Wiki Index

Note: These pages are being reviewed.

  • To add the Copy/Delete/Move/Rename action to your project’s node, you should:

    1. Implement the corresponding interface such as org.netbeans.spi.project.CopyOperationImplementation.

    2. Implement org.netbeans.spi.project.ActionProvider:

public final class AddActionActions implements ActionProvider {
    private final AddActionProject project; //suppose this is your project
    public AddActionActions(AddActionProject project) {
        this.project = project;
    public String[] getSupportedActions() {
        return new String[] {
    public boolean isActionEnabled(String command, Lookup context) {
        if (command.equals(ActionProvider.COMMAND_COPY)) {
            return true;
        } else {
            throw new IllegalArgumentException(command);
    public void invokeAction(String command, Lookup context) {
        if (command.equalsIgnoreCase(ActionProvider.COMMAND_COPY)){
  1. 1. Add these implementations to your project’s lookup:

lookup = Lookups.fixed(
    // ... as before
    new AddActionOperation(this),
    new AddActionActions(this),
  1. 1. Register the actions into the project node’s context menu:

public @Override Action[] getActions(boolean context) {
    Action[[ | ]] nodeActions = new Action[2];
    nodeActions[0] = CommonProjectActions.copyProjectAction();
    nodeActions[1] = CommonProjectActions.closeProjectAction();
    return nodeActions;
  • To add the other actions specified in the Project API such as closeProjectAction, just add it to the list of actions of your node.

  • To add an action you created yourself, just add it to the list of actions of your node.