Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bypassing Lock on Generated Code in NetBeans 6.5?

In NetBeans the GUI Builder generates code that is off limits to you from the editor.

I know you can switch to Design Mode and specify custom code and then enter edit in indirectly that way, but it's a pain to not be able to edit text that's 2 lines from your cursor.

Can I allow editing within those regions... I promise I'll be careful :)

Thanks.

Note: I don't want to lose code generation

like image 827
Allain Lalonde Avatar asked Dec 18 '22 09:12

Allain Lalonde


2 Answers

If you open it in an external editor, there are two possibilities:

  • there is no guarantee that the changes you make will work (and not break anything) in the Netbeans UI Editor
  • The next time you edit the file in Netbeans it will be regenerated.

Either way, probably not what you want. The best thing to do would probably be to make the whole design up in the gui editor and when you are happy with it, delete the comments and continue on.

[sarcasm] With the drag and drop gui editor, what could you possibly want to change by hand anyway? [/sarcasm] ;)

like image 143
SeanJA Avatar answered Jan 05 '23 17:01

SeanJA


If you open the .java files in Notepad or WordPad, you'll find pairs of comments that say

// GEN-BEGIN: <name of section>
...
// GEN-END: <name of section>

Delete those comments, and two things will happen.

  1. You'll be able to edit anywhere in the file in NetBeans.
  2. NetBeans will not be able to regenerate the file from the GUI editor.

So it can be done, but don't do it unless you really mean it.


EDIT: "Note: I don't want to lose code generation." Ok, let's see here.

  1. You want to change what is generated.
  2. You don't want to lose code generation.
  3. You don't want to use the facilities NetBeans provides for adding custom code.

It sounds like you're wishing yourself trouble. :D

like image 27
Michael Myers Avatar answered Jan 05 '23 17:01

Michael Myers