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.

Bug 193569 - gridBagConstraints.anchor is set to null
Summary: gridBagConstraints.anchor is set to null
Status: RESOLVED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal (vote)
Assignee: issues@guibuilder
URL:
Keywords:
: 197990 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-12-18 09:12 UTC by kvaso
Modified: 2011-04-26 12:22 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kvaso 2010-12-18 09:12:50 UTC
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)
Comment 1 Jan Stola 2011-04-26 09:14:33 UTC
*** Bug 197990 has been marked as a duplicate of this bug. ***
Comment 2 Jan Stola 2011-04-26 12:02:32 UTC
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.
Comment 3 Jan Stola 2011-04-26 12:18:16 UTC
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)
...
Comment 4 Jan Stola 2011-04-26 12:22:58 UTC
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