Can I edit the blue, guarded blocks of code when developing a GUI?
Yes, you can do it by editing special "code" properties. Selected a component, go to the Properties window and select the Code tab.
You can completely replace the way components are instantiated (Custom Creation Code), add code before or after creation and properties initialization. The only difference is that this code is stored in the XML .form file, so it is included when the guarded code is regenerated.
However, please note that you can easily write your code out of the guarded block, typically into the constructor after the initComponents() method call, as additional setup code that should be performed. This option is often forgotten, but it is the most eficient and easiset way to add custom code, working in most situation (e.g. except custom instantiation code).
If you're writing a fairly simple bean, you may not want to use the GUI editor for that. But, if you have a burning desire to edit the contents of guarded blocks (again, do try the Code options — you have complete control over instantiation and initialization), copy your class and paste it into a generic class template. You won't be able to use the form editor to edit the results, but if you get your basic gui set up, that will work. Either approach will get you the results you want, use whichever you're more comfortable with.
Applies to: All NetBeans versions