The new editor includes a palette. And, in exactly the same way as described for HTML files, palette items can be added to this palette. The module has the same shortcomings as the one for HTML palette items: you can't specify a label or an icon for the palette item, but to overcome that, you're given a list of item names and icons that you can select. Even though this is not very nice, it works well enough for when you're working with bits of code that you want to reuse elsewhere or store for safekeeping somewhere where it won't get lost (the palette is persisted across restarts and only if you remove the user directory will you lose your palette items).
So, first you make a selection in a Java file. Then you right-click in the Source Editor (or you could map the action to a keyboard shortcut) and choose "Add to Palette":
Next, you get a dialog box where you can view and modify the selected code. Here's also where you chose a label and an icon. (The labels provided are things like "class_1", "class_2", "method_1", "field_1", and there is a very long list of them.) This is what the dalog box looks like:
Note that the edit area is basically a Java editor. So, apart from the syntax highlighting, you can right-click it and get all the Source Editor's functionality for Java files, such as "Reformat Code". Maybe it would be nice if the module could work out what is under the cursor and then assign an appropriate name. But, there's no guarantee that the user will only want to create snippets of neat little methods and fields. Maybe big chunks, encapsulating a variety of methods, fields, and so on, would be selected by the user, so that's why I decided it was best to just let the user select a label, rather than getting the module to do that for you.
Then you click OK. And now you have a new item in your palette:
When you drop that item in a Java file, the IDE will paste the code snippet that you selected at the start of this procedure. If someone is interested in this module, please let me know. I have it available for NetBeans IDE 5.0, but making it ready for 5.5 should not be much work.