Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 352568

Summary: NPE while parsing dialog with custom content pane
Product: z_Archived Reporter: Missing name <fatalbender>
Component: WindowBuilderAssignee: Konstantin Scheglov <Konstantin.Scheglov>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Konstantin.Scheglov
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Report generated by WB. Contains source on which bug can be reproduced. none

Description Missing name CLA 2011-07-20 08:35:18 EDT
Build Identifier: I20110613-1736

Parsing of NetBeans-generated dialog fails when constructor contains setContentPane(new JPanel()) line. With that line commented out everything is ok.

First lines of stack trace:
java.lang.NullPointerException
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:187)
	at com.google.common.collect.CustomConcurrentHashMap.hash(CustomConcurrentHashMap.java:1432)


Reproducible: Always
Comment 1 Missing name CLA 2011-07-20 08:37:35 EDT
Created attachment 199988 [details]
Report generated by WB. Contains source on which bug can be reproduced.
Comment 2 Konstantin Scheglov CLA 2011-07-28 10:39:56 EDT
This is unsupported code style.
WindowBuilder does not understand that setContentPane() causes returning different result from getContentPane().
We don't have plans to fix this.

Try to generate new JFrame using wizard with "advanced" template, and configure Swing | Code Generation to use "initComponents" method.
Then drop GroupLayout and see how code should look like to be understood by WindowBuilder.
Comment 3 Missing name CLA 2011-08-03 04:17:13 EDT
It seems i expecting too much from WB. Of course it can't do magic and parse whatever human wrote.

Generally, the bug itself is not a big problem. In my project custom content pane used only for tweaking of dialog appearance. Approach "comment line -> use WB designer -> uncomment line" is quite acceptable.

The only thing that really needed here is some friendly message about setContentPane. "Go to problem" button sends us to last line of code in initializer, not to "setContentPane(new JPanel())". I was dissapointed with this ("What am i doing wrong?") and spent some time on cutting parts of real-life dialog to discover problem line.
Comment 4 Konstantin Scheglov CLA 2011-08-03 12:36:30 EDT
Unfortunately sometimes exception like this is really "exception", i.e. something what is not expected by WindowBuilder, and having support for identifying such cases is not easier than adding support for it.
Comment 5 Konstantin Scheglov CLA 2011-08-03 15:49:56 EDT
OK, I have one idea how to solve this.
Comment 6 Konstantin Scheglov CLA 2011-08-03 15:50:24 EDT
Fixed in trunk.