Next in the JFugue Music NotePad, I am working on creating a "cut action", which means integrating with the NetBeans Platform cut action. As you can see below, when (and only when) one or more notes are selected, the cut action (look in the toolbar) becomes enabled:

How to do this yourself? Inside the TopComponent, I have these two lines of code, which links the "cut-to-clipboard" action to an action registered in the layer:final ActionMap actionMap = getActionMap();actionMap.put("cut-to-clipboard", Utilities.actionsForPath("Actions/Bla/").get(0));
Then, in the layer, the first action registered in "Actions/Bla" is as follows:
Take note of the fact that the "type" element enables all (thanks to "ANY") available Note objects to be injected into the action registered for the "injectable" element.
That's all. Now the "injectable" action can receive a List of Note objects and can do with them what they want. Which Note objects are injected? Those that are available via the Lookup. Personally, I'm using Wade Chandler's central lookup, which is an amazing thing, meaning that I am not tied to any windows or even to the current selection.


Read More about [Connecting the Cut Action to a Context Aware Action...