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.
Consider the following test-case (assumes that JXDatePicker from SwingX library is installed in the Palette): 1. Create new Java Application. 2. Create new JFrame form. 3. Put JXDatePicker into the form. 4. Preview the form - it works correctly. 5. Clean and build the project. 6. Preview the form again - exception is thrown. java.lang.NullPointerException at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:164) at org.jdesktop.swingx.plaf.LookAndFeelAddons.getUI(LookAndFeelAddons.java:280) at org.jdesktop.swingx.JXMonthView.updateUI(JXMonthView.java:792) at org.jdesktop.swingx.JXMonthView.<init>(JXMonthView.java:341) at org.jdesktop.swingx.JXMonthView.<init>(JXMonthView.java:281) at org.jdesktop.swingx.JXDatePicker.initMonthView(JXDatePicker.java:272) at org.jdesktop.swingx.JXDatePicker.init(JXDatePicker.java:263) at org.jdesktop.swingx.JXDatePicker.<init>(JXDatePicker.java:192) at org.jdesktop.swingx.JXDatePicker.<init>(JXDatePicker.java:143) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at java.lang.Class.newInstance0(Class.java:350) at java.lang.Class.newInstance(Class.java:303) at org.netbeans.modules.form.CreationFactory.createDefaultInstance(CreationFactory.java:165) at org.netbeans.modules.form.RADComponent.createBeanInstance(RADComponent.java:229) [catch] at org.netbeans.modules.form.RADComponent.cloneBeanInstance(RADComponent.java:355) at org.netbeans.modules.form.VisualReplicator.cloneComponent(VisualReplicator.java:666) at org.netbeans.modules.form.VisualReplicator.cloneComponent(VisualReplicator.java:704) at org.netbeans.modules.form.VisualReplicator.createClone(VisualReplicator.java:182) at org.netbeans.modules.form.VisualReplicator.createClone(VisualReplicator.java:170) at org.netbeans.modules.form.FormDesigner$4.run(FormDesigner.java:560) at org.netbeans.modules.form.FormLAF$2.run(FormLAF.java:255) 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:240) at org.netbeans.modules.form.FormDesigner.createFormView(FormDesigner.java:555) at org.netbeans.modules.form.actions.TestAction.run(TestAction.java:137)
There is a simple workaround - just reload (or close and reopen) the form. The root of this problem is a modification of project's classloader during compilation. The hacks that allow previews in different look and feels require usage of disjoint UIDefaults for individual classloaders. The mentioned change in classloader causes flush of previously installed defaults. Unfortunately, the component in view is loaded by the old classloader and hence requires the old defaults (during cloning). The only solution I am aware of by now is to make sure that just one classloader is used for visualization e.g. to force reload of the form when project's classloader is changed. It current infrastructure requires saving of the form before reload. This may be annoying when project's classpath is modified as a result of form modification e.g. new custom component is added to form or the first binding is created.
But, with just one classloader, do you think preview for different L&F will work? Some SwingX components as JXTaskPane have different look for different L&Fs. There is a issue https://swingx.dev.java.net/issues/show_bug.cgi?id=753 which I think is related with this behavior. Regards.
As it is described in SwingX issue 753 - the 3rd party components will never be correctly displayed in other look and feels (if they use other than standard UI resources). The design of UIManager is not good and hence some things are not possible, unfortunately.
*** Bug 216599 has been marked as a duplicate of this bug. ***
*** Bug 216860 has been marked as a duplicate of this bug. ***
*** Bug 223384 has been marked as a duplicate of this bug. ***
*** Bug 212751 has been marked as a duplicate of this bug. ***
*** Bug 227487 has been marked as a duplicate of this bug. ***
*** Bug 227204 has been marked as a duplicate of this bug. ***
Implemented a simple workaround - reloading the component classes whenever the components need to be cloned. It should help with the problems reported here, but not a perfect solution and somewhat increasing risk of ClassCastException, so done only for SwingX components. http://hg.netbeans.org/jet-main/rev/57ca7332910e
Integrated into 'main-silver', will be available in build *201401180001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/57ca7332910e User: Tomas Pavek <tpavek@netbeans.org> Log: #127881: load fresh classes when cloning SwingX components so they get to UIDefaults of the newest classloader
*** Bug 242074 has been marked as a duplicate of this bug. ***