Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352568 - NPE while parsing dialog with custom content pane
Summary: NPE while parsing dialog with custom content pane
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: WindowBuilder (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Konstantin Scheglov CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-20 08:35 EDT by Missing name CLA
Modified: 2021-06-04 16:45 EDT (History)
1 user (show)

See Also:


Attachments
Report generated by WB. Contains source on which bug can be reproduced. (5.51 KB, application/octet-stream)
2011-07-20 08:37 EDT, Missing name CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.