This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
1. create new JFrame class (Swing GUI Forms -> JFrame Form) 2. place any component into a form (using GUI builder) 3. change layout from Free Design to GridBagLayout 4. an error raises on line containing: "gridBagConstraints.anchor = null;" (btw. this bug is present since netbeans 6.9)
*** Bug 197990 has been marked as a duplicate of this bug. ***
I was able to reproduce this bug. There is a simple workaround: 1. Change the layout => anchor = null statements get generated. 2. Close and Save the file. 3. Open the file again. 4. Perform some dummy change in the GUI design to force regeneration of the source code => anchor = null statements are fixed.
The following exception was swallowed along the way: java.lang.NullPointerException at java.util.Hashtable.get(Hashtable.java:334) at o.n.m.form.FormEditor.getFormDataObject(FormEditor.java:1175) at o.n.m.form.layoutsupport.delegates.GridBagLayoutSupport$AnchorEditor .setContext(GridBagLayoutSupport.java:1161) at o.n.m.form.FormPropertyContext$EmptyImpl .initPropertyEditor(FormPropertyContext.java:166) at o.n.m.form.FormProperty.getCurrentEditor(FormProperty.java:653) at o.n.m.form.FormProperty.getJavaInitializationString(FormProperty.java:709) at o.n.m.form.codestructure.FormCodeSupport$FormPropertyValueOrigin .getJavaCodeString(FormCodeSupport.java:204) at o.n.m.form.JavaCodeGenerator .getExpressionJavaString(JavaCodeGenerator.java:3123) at o.n.m.form.JavaCodeGenerator .getStatementJavaString(JavaCodeGenerator.java:3092) at o.n.m.form.JavaCodeGenerator .generateComponentAddCode(JavaCodeGenerator.java:1850) ...
While it would be nice to identify why AnchorEditor is not given a non-empty context, a workaround for the mentioned NPE is sufficient to make the described test-case to work correctly => marking as fixed. Modified file: http://hg.netbeans.org/jet-main/rev/89aa6d841241