Create custom button in NetBeans toolbar PROGRAMATICALLY

Is it possible to create a button in Netbeans toolbar programatically?

Current situation:
I have a .bat files that I want to run after click or shortcut use from netbeans. For each separate file I create Action in my module, pack and re-install it into IDE.
The code of each action is pretty much the same

package com.force.GlfToolbar;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionRegistration;
import org.openide.util.NbBundle.Messages;

        category = "File",
        id = "com.force.GlfToolbar.NpwActionListener"
        iconBase = "com/force/GlfToolbar/npw-icon.png",
        displayName = "#CTL_NpwActionListener"
@ActionReference(path = "Toolbars/File", position = 0)
@Messages("CTL_NpwActionListener=NPW build")
public final class NpwBuildActionListener implements ActionListener {

    public void actionPerformed(ActionEvent e) {
        try {
            Runtime.getRuntime().exec("cmd /c start c:/APPS/nb-builds/build_npw.bat");
        } catch (IOException ex) {
            Logger.getLogger(NpwBuildActionListener.class.getName()).log(Level.SEVERE, null, ex);

Desired situation:
I create new .bat after which new button appears in Netbeans automatically (after start), representing this bat.

Source: java

1 Comment

  1. Geertjan

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.