NB: How do I create an action which can be invoked by a macro?

Use @EditorActionRegistration!

@NbBundle.Messages({ "CTL_MyAction=Let's go", "macro-name=Let's go" })
@EditorActionRegistration(
	name = "macro-name", 
	mimeType = "text/x-java", 
	menuPath = "Source", menuPosition = 0, menuText = "#CTL_MyAction")
public class MyAction extends org.netbeans.editor.BaseAction {
 //...
}

Now your action can be invoked by a macro using its macroname (the name attribute in the @EditorActionRegistration-Annotation) and even recorded by the macro recorder.

[1] http://wiki.netbeans.org/DevFaqAddMacroableAction

Advertisements