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 166092

Summary: Preview Design - Nimbus does not work
Product: guibuilder Reporter: pribyl <pribyl>
Component: CodeAssignee: issues@guibuilder <issues>
Status: VERIFIED FIXED    
Severity: blocker CC: hmichel, ldlopez, sustaining
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
URL: http://statistics.netbeans.org/exceptions/detail.do?id=151851
Issue Type: DEFECT Exception Reporter: 151851
Attachments: stacktrace
stacktrace

Description pribyl 2009-05-27 11:31:14 UTC
Build: NetBeans IDE 6.7 RC1 (Build 200905270001)
VM: Java HotSpot(TM) Client VM, 14.0-b12, Java(TM) SE Runtime Environment, 1.6.0_14-ea-b03
OS: Windows XP, 5.1, x86

User Comments:
pribyl: Invoked Preview Design > Nimbus



Stacktrace: 
java.lang.NullPointerException
        at java.awt.Container.addImpl(Container.java:1045)
        at java.awt.Container.add(Container.java:365)
        at org.netbeans.modules.form.layoutdesign.support.SwingLayoutBuilder.createLayout(SwingLayoutBuilder.java:172)
        at org.netbeans.modules.form.layoutdesign.support.SwingLayoutBuilder.setupContainerLayout(SwingLayoutBuilder.java:107)
        at org.netbeans.modules.form.VisualReplicator.setupContainerLayout(VisualReplicator.java:815)
        at org.netbeans.modules.form.VisualReplicator.cloneComponent(VisualReplicator.java:747)
Comment 1 pribyl 2009-05-27 11:31:24 UTC
Created attachment 82850 [details]
stacktrace
Comment 2 pribyl 2009-05-27 11:43:25 UTC
Product Version: NetBeans IDE 6.7 RC1 (Build 200905270001)
Java: 1.6.0_14-ea; Java HotSpot(TM) Client VM 14.0-b12
System: Windows XP version 5.1 running on x86; Cp1250; cs_CZ (nb)

Preview Design > Nimbus does nothing. Other previews  works as expected.

Exceptions can be seen in the IDE log.

Once an Exception was thrown (and I reported it using Exception reporter), but I was not able to reproduce this one.
Comment 3 leopard2av 2009-06-24 15:55:19 UTC
Also on 6.5 with nimbus l&f.  
Comment 4 pribyl 2009-06-26 11:09:40 UTC
I guess this should be fixed in upcoming patch.
I know it is not a big issue, but it does not look good - other L&F previews works fine, only poor Nimbus does not :)
Comment 5 ldlopez 2009-06-27 14:08:58 UTC
Thanks for answering.

Yes, only with Nimbus it has problems. The problem already presents to the version 6.5.1 of NetBeans.

Good bye
Comment 6 Tomas Pavek 2009-07-06 11:48:49 UTC
The root cause exception seems to be this:

java.lang.NullPointerException
at com.sun.java.swing.plaf.nimbus.NimbusStyle.init(NimbusStyle.java:418)
at com.sun.java.swing.plaf.nimbus.NimbusStyle.validate(NimbusStyle.java:359)
at com.sun.java.swing.plaf.nimbus.NimbusStyle.getValues(NimbusStyle.java:927)
at com.sun.java.swing.plaf.nimbus.NimbusStyle.getInsets(NimbusStyle.java:605)
at javax.swing.plaf.synth.SynthStyle.installDefaults(SynthStyle.java:896)
at javax.swing.plaf.synth.SynthLookAndFeel.updateStyle(SynthLookAndFeel.java:276)
at javax.swing.plaf.synth.SynthPanelUI.updateStyle(SynthPanelUI.java:70)
at javax.swing.plaf.synth.SynthPanelUI.installDefaults(SynthPanelUI.java:57)
at javax.swing.plaf.basic.BasicPanelUI.installUI(BasicPanelUI.java:39)
at javax.swing.plaf.synth.SynthPanelUI.installUI(SynthPanelUI.java:37)
at javax.swing.JComponent.setUI(JComponent.java:673)
at javax.swing.JPanel.setUI(JPanel.java:136)
at javax.swing.JPanel.updateUI(JPanel.java:109)
at javax.swing.JPanel.<init>(JPanel.java:69)
at javax.swing.JPanel.<init>(JPanel.java:92)
at javax.swing.JPanel.<init>(JPanel.java:100)
at javax.swing.JRootPane.createGlassPane(JRootPane.java:528)
at javax.swing.JRootPane.<init>(JRootPane.java:348)
at javax.swing.JFrame.createRootPane(JFrame.java:260)
at javax.swing.JFrame.frameInit(JFrame.java:241)
at javax.swing.JFrame.<init>(JFrame.java:164)
...

It seems specific to JDK 1.6.0_14, since it works fine for me on 1.6.0_10. NimbusStyle.validate changed in u14, it 
seems missing something in UIDefaults now.
Comment 7 Jan Stola 2009-07-07 15:28:13 UTC
There were several changes in JDK 1.6u14 in Nimbus area that caused these problems.

java.lang.NullPointerException
at com.sun.java.swing.plaf.nimbus.NimbusStyle.init(NimbusStyle.java:418)
at com.sun.java.swing.plaf.nimbus.NimbusStyle.validate(NimbusStyle.java:359)
at com.sun.java.swing.plaf.nimbus.NimbusStyle.getValues(NimbusStyle.java:927)
at com.sun.java.swing.plaf.nimbus.NimbusStyle.getInsets(NimbusStyle.java:605)
at javax.swing.plaf.synth.SynthStyle.installDefaults(SynthStyle.java:896)
...

NimbusStyle.validate() invokes NimbusStyle.compileDefaults() that uses
UIManager.getLookAndFeelDefaults().entrySet() to obtain the set of name-value
pairs. Our FormLAF.DelegatingDefaults didn't have entrySet() method overriden
e.g. didn't delegate this call correctly.

Once this issue was fixed, the following exception appeared:

java.lang.ClassCastException: org.netbeans.swing.plaf.util.GuaranteedValue cannot be cast to java.awt.Color
	at com.sun.java.swing.plaf.nimbus.NimbusDefaults$ColorTree.propertyChange(NimbusDefaults.java:1653)
	at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
	at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(SwingPropertyChangeSupport.java:75)
	at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
	at javax.swing.UIDefaults.firePropertyChange(UIDefaults.java:827)
	at javax.swing.UIDefaults.put(UIDefaults.java:330)
	at java.util.Hashtable.putAll(Hashtable.java:466)
	at org.netbeans.modules.form.FormLAF.useIDELookAndFeel(FormLAF.java:354)
	at org.netbeans.modules.form.FormLAF.access$300(FormLAF.java:63)
	at org.netbeans.modules.form.FormLAF$2.run(FormLAF.java:278)
	at org.openide.util.Mutex.doEventAccess(Mutex.java:1355)
	at org.openide.util.Mutex.readAccess(Mutex.java:317)
	at org.netbeans.modules.form.FormLAF.executeWithLookAndFeel(FormLAF.java:259)
	at org.netbeans.modules.form.FormDesigner.createFormView(FormDesigner.java:580)
        ...

This can be considered as a bug either in UIDefaults or in NimbusDefaults. The problem is that
NimbusDefaults$ColorTree.propertyChange obtains UIDefaults.LazyValue, but it assumes that it will
get resolved value e.g. java.awt.Color in this case.

I have implemented a workaround for that - we resolve all LazyValues during initialization of preview
look and feel.

Finally, there were some changes in NimbusLookAndFeel listeners that made our preview very inaccurate. I have fixed 
that as well.

Modified file: http://hg.netbeans.org/cdev/rev/2ea9ad9e0fcb

The support of preview in a different look and feel is very fragile (it is not supported by Swing and the whole 
implementation is just a set of hacks). Therefore, I cannot guarantee that the fix doesn't have unexpected negative 
consequences. Hence, I believe that we shouldn't include it in the first patch for NB 6.7. I suggest to postpone it 
into some subsequent patch (once we verify that the fix is harmless).
Comment 8 Marian Mirilovic 2009-07-08 13:57:18 UTC
verified in NB Dev (20090708)
Comment 9 pribyl 2009-07-08 14:56:59 UTC
Product Version: NetBeans IDE Dev (Build 200907080200)
Java: 1.6.0_14; Java HotSpot(TM) Client VM 14.0-b16
System: Windows XP version 5.1 running on x86; Cp1250; cs_CZ (nb)

Verified as well :)

Today I tried to preview quite a lot different form files with many components in Nimbus LaF.Everything seems to be
stable, I did not noticed any negative impact of this fix.
Comment 10 pgebauer 2009-07-08 16:49:44 UTC
The fix has been ported into the release67_fixes repository.
http://hg.netbeans.org/release67_fixes/rev/3d01898527fc
Comment 11 Jan Becicka 2009-07-09 14:00:12 UTC
*** Issue 167943 has been marked as a duplicate of this issue. ***
Comment 12 Petr Dvorak 2009-07-09 14:01:19 UTC
*** Issue 167943 has been marked as a duplicate of this issue. ***
Comment 13 Michel Graciano 2009-09-01 11:53:39 UTC
Build: NetBeans IDE Dev (Build 200909010201)
VM: Java HotSpot(TM) Client VM, 14.2-b01, Java(TM) SE Runtime Environment, 1.6.0_16-b01
OS: Linux, 2.6.28-15-generic, i386

User Comments: 


Stacktrace: 
java.lang.NullPointerException
        at java.awt.Container.addImpl(Container.java:1045)
        at java.awt.Container.add(Container.java:365)
        at org.netbeans.modules.form.layoutdesign.support.SwingLayoutBuilder.createLayout(SwingLayoutBuilder.java:172)
        at org.netbeans.modules.form.layoutdesign.support.SwingLayoutBuilder.setupContainerLayout(SwingLayoutBuilder.java:107)
        at org.netbeans.modules.form.VisualReplicator.setupContainerLayout(VisualReplicator.java:815)
        at org.netbeans.modules.form.VisualReplicator.cloneComponent(VisualReplicator.java:747)
Comment 14 Michel Graciano 2009-09-01 11:53:43 UTC
Created attachment 86905 [details]
stacktrace