
Monday May 12, 2008
When Inserting Code Fails, Try Encapsulating Fields
Hi all,
I experienced some weird behavior today when I was working on a tutorial for Hibernate. I wanted to generate some getters and setters, so I right-clicked in the Source Editor and chose Insert Code. Nothing happened. I mean nothing. Literally. It should have looked like this:

I tried it again and again. Still nothing. So I did what any other tech writer would do: I tried it another way. I right-clicked again in the Source Editor and choose Refactor > Encapsulate Fields.

Here I was able to get the IDE to generate my getter and setter methods, getting the result I desired.
From what I understand, the problems could have been caused by where the cursor is located in the Source Editor. Since hearing about this, however, I've gone back and tried it again. Sometimes I was able to insert code, other times not.
One great thing about NetBeans is that there is often an alternate way of getting something done.
Cheers!
--James
Posted by branajam
( May 12 2008, 01:40:40 PM CEST )
Permalink
James,
Personally, I always use Refactor>Encapsulate to generate the setter and getters
Cheers,
John
Posted by John Vickio on May 12, 2008 at 06:10 PM CEST #