How to modify/add code to the initComponents()
method in Java on NetBeans? When I try to add any line of code this area seems to be like readonly and it\'s high
To allow changes in both the source and the Matisse GUI editor, NetBeans prevents editing in what it calls "guarded blocks". While you could imagine the IDE being able to interpret almost any kind of GUI code you write, in practice, it is much easier for the IDE developers to encapsulate the automatically generated GUI code in a single method (initComponents()) and leave the rest for you to edit.
If you are certain you know what you're doing, you can easily edit the .java file from an external editor, but:
If you right-click on the component in the Design View
, and then click on "Customize Code
" selection, you can modify the code in the InitComponent
code. Several lines of explicit code can be customized.