NPE 使用 GTK LAF 运行 Netbeans 时
最近,我在 netbeans 日志中得到了一个奇怪的堆栈跟踪(我将其添加到本文的末尾)。我能够追踪到 LAF。当使用 GTK LAF 运行 Netbeans 时,会发生此错误,但在 Metal 和使用本机 Windows LAF 中运行良好。
看起来,PropertyChangeSupport 实例是 NULL,因此在添加属性更改侦听器时会抛出错误。这是我的自定义组件的缩写源:
public class EnterprisePicker extends javax.swing.JPanel implements ActionListener, KeyListener, ListSelectionListener, UnitContainer {
private static final Logger logger = IdeUiUtil.initLogger(EnterprisePicker.class.getName());
protected InfoPanelStyle infoPanelStyle = InfoPanelStyle.FULL;
private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
public static final String PROP_INFOPANELSTYLE = "infoPanelStyle";
/** Creates the new component */
public EnterprisePicker() {
// [... snip ...]
}
// [ ... snip ... ]
/**
* Add PropertyChangeListener.
*
* @param listener
*/
@Override
public void addPropertyChangeListener(PropertyChangeListener listener) {
propertyChangeSupport.addPropertyChangeListener(listener);
}
// [ ... snip ... ]
}
显然,我可以简单地使用 if (propertyChangeSupport == null) 保护这些调用...但这不会破坏应用程序中的属性吗?假设由于实例为 null
,因此不会附加任何侦听器...?
堆栈跟踪
INFO [org.netbeans.modules.form.BeanSupport]: Cannot create default instance of: org.statec.ide.ui.components.EnterprisePicker
java.lang.NullPointerException
at org.statec.ide.ui.components.EnterprisePicker.addPropertyChangeListener(EnterprisePicker.java:654)
at javax.swing.plaf.synth.SynthPanelUI.installListeners(SynthPanelUI.java:49)
at javax.swing.plaf.synth.SynthPanelUI.installUI(SynthPanelUI.java:38)
at javax.swing.JComponent.setUI(JComponent.java:662)
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 org.statec.ide.ui.components.EnterprisePicker.<init>(EnterprisePicker.java:39)
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:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.netbeans.modules.form.CreationFactory.createDefaultInstance(CreationFactory.java:168)
[catch] at org.netbeans.modules.form.BeanSupport.createBeanInstance(BeanSupport.java:83)
at org.netbeans.modules.form.BeanSupport.getDefaultInstance(BeanSupport.java:109)
at org.netbeans.modules.form.GandalfPersistenceManager.restoreComponent(GandalfPersistenceManager.java:769)
at org.netbeans.modules.form.GandalfPersistenceManager.loadComponent(GandalfPersistenceManager.java:1007)
at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:527)
at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:299)
at org.netbeans.modules.form.FormEditor$3.run(FormEditor.java:337)
at org.netbeans.modules.form.FormLAF$2.run(FormLAF.java:293)
at org.openide.util.Mutex.doEventAccess(Mutex.java:1361)
at org.openide.util.Mutex.readAccess(Mutex.java:320)
at org.netbeans.modules.form.FormLAF.executeWithLookAndFeel(FormLAF.java:276)
at org.netbeans.modules.form.FormEditor.loadFormData(FormEditor.java:334)
at org.netbeans.modules.form.FormEditor.loadFormDesigner(FormEditor.java:232)
at org.netbeans.modules.form.FormDesigner.finishComponentShowing(FormDesigner.java:1932)
at org.netbeans.modules.form.FormDesigner.access$1100(FormDesigner.java:107)
at org.netbeans.modules.form.FormDesigner$PreLoadTask$1.run(FormDesigner.java:1897)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:602)
at java.awt.EventQueue$1.run(EventQueue.java:600)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:148)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
INFO
org.openide.ErrorManager$AnnException: msg
at org.openide.ErrorManager$AnnException.findOrCreate(ErrorManager.java:866)
at org.openide.ErrorManager$DelegatingErrorManager.annotate(ErrorManager.java:653)
at org.netbeans.modules.form.GandalfPersistenceManager.annotateException(GandalfPersistenceManager.java:237)
at org.netbeans.modules.form.GandalfPersistenceManager.annotateException(GandalfPersistenceManager.java:247)
at org.netbeans.modules.form.GandalfPersistenceManager.restoreComponent(GandalfPersistenceManager.java:865)
at org.netbeans.modules.form.GandalfPersistenceManager.loadComponent(GandalfPersistenceManager.java:1007)
at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:527)
at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:299)
at org.netbeans.modules.form.FormEditor$3.run(FormEditor.java:337)
at org.netbeans.modules.form.FormLAF$2.run(FormLAF.java:293)
at org.openide.util.Mutex.doEventAccess(Mutex.java:1361)
at org.openide.util.Mutex.readAccess(Mutex.java:320)
at org.netbeans.modules.form.FormLAF.executeWithLookAndFeel(FormLAF.java:276)
at org.netbeans.modules.form.FormEditor.loadFormData(FormEditor.java:334)
at org.netbeans.modules.form.FormEditor.loadFormDesigner(FormEditor.java:232)
at org.netbeans.modules.form.FormDesigner.finishComponentShowing(FormDesigner.java:1932)
at org.netbeans.modules.form.FormDesigner.access$1100(FormDesigner.java:107)
at org.netbeans.modules.form.FormDesigner$PreLoadTask$1.run(FormDesigner.java:1897)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:602)
at java.awt.EventQueue$1.run(EventQueue.java:600)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:148)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
msg
Caused: java.lang.NullPointerException
at org.statec.ide.ui.components.EnterprisePicker.addPropertyChangeListener(EnterprisePicker.java:654)
at javax.swing.plaf.synth.SynthPanelUI.installListeners(SynthPanelUI.java:49)
at javax.swing.plaf.synth.SynthPanelUI.installUI(SynthPanelUI.java:38)
at javax.swing.JComponent.setUI(JComponent.java:662)
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 org.statec.ide.ui.components.EnterprisePicker.<init>(EnterprisePicker.java:39)
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:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.netbeans.modules.form.CreationFactory.createDefaultInstance(CreationFactory.java:168)
at org.netbeans.modules.form.RADComponent.createBeanInstance(RADComponent.java:252)
at org.netbeans.modules.form.RADComponent.initInstance(RADComponent.java:191)
at org.netbeans.modules.form.GandalfPersistenceManager.restoreComponent(GandalfPersistenceManager.java:851)
at org.netbeans.modules.form.GandalfPersistenceManager.loadComponent(GandalfPersistenceManager.java:1007)
at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:527)
at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:299)
at org.netbeans.modules.form.FormEditor$3.run(FormEditor.java:337)
at org.netbeans.modules.form.FormLAF$2.run(FormLAF.java:293)
at org.openide.util.Mutex.doEventAccess(Mutex.java:1361)
at org.openide.util.Mutex.readAccess(Mutex.java:320)
at org.netbeans.modules.form.FormLAF.executeWithLookAndFeel(FormLAF.java:276)
at org.netbeans.modules.form.FormEditor.loadFormData(FormEditor.java:334)
[catch] at org.netbeans.modules.form.FormEditor.loadFormDesigner(FormEditor.java:232)
at org.netbeans.modules.form.FormDesigner.finishComponentShowing(FormDesigner.java:1932)
at org.netbeans.modules.form.FormDesigner.access$1100(FormDesigner.java:107)
at org.netbeans.modules.form.FormDesigner$PreLoadTask$1.run(FormDesigner.java:1897)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:602)
at java.awt.EventQueue$1.run(EventQueue.java:600)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:148)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Error in loading component: [JDialog]->enterprisePicker1
Cannot create instance of org.statec.ide.ui.components.EnterprisePicker.
The component cannot be loaded.
并供参考:
malbert@dredg:~/.netbeans/7.0/var/log$ java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)
malbert@dredg:~/.netbeans/7.0/var/log$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=11.04
DISTRIB_CODENAME=natty
DISTRIB_DESCRIPTION="Ubuntu 11.04"
Recently, I got a weird stack trace in the netbeans logs (I added it to the end of this post). I was able to track it down to the LAF. This error happens, when running Netbeans using the GTK LAF, but works fine in Metal, and using the native Windows LAF.
It seems, that the PropertyChangeSupport instance is NULL, so it throws an error when adding a Property change listener. Here's the abbreviated source of my custom component:
public class EnterprisePicker extends javax.swing.JPanel implements ActionListener, KeyListener, ListSelectionListener, UnitContainer {
private static final Logger logger = IdeUiUtil.initLogger(EnterprisePicker.class.getName());
protected InfoPanelStyle infoPanelStyle = InfoPanelStyle.FULL;
private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
public static final String PROP_INFOPANELSTYLE = "infoPanelStyle";
/** Creates the new component */
public EnterprisePicker() {
// [... snip ...]
}
// [ ... snip ... ]
/**
* Add PropertyChangeListener.
*
* @param listener
*/
@Override
public void addPropertyChangeListener(PropertyChangeListener listener) {
propertyChangeSupport.addPropertyChangeListener(listener);
}
// [ ... snip ... ]
}
Obviously I could simply protect these calls using if (propertyChangeSupport == null)
... But would that not break properties later on in the application? Assuming that no listener will ever be attached as the instance is null
...?
Stack Trace
INFO [org.netbeans.modules.form.BeanSupport]: Cannot create default instance of: org.statec.ide.ui.components.EnterprisePicker
java.lang.NullPointerException
at org.statec.ide.ui.components.EnterprisePicker.addPropertyChangeListener(EnterprisePicker.java:654)
at javax.swing.plaf.synth.SynthPanelUI.installListeners(SynthPanelUI.java:49)
at javax.swing.plaf.synth.SynthPanelUI.installUI(SynthPanelUI.java:38)
at javax.swing.JComponent.setUI(JComponent.java:662)
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 org.statec.ide.ui.components.EnterprisePicker.<init>(EnterprisePicker.java:39)
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:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.netbeans.modules.form.CreationFactory.createDefaultInstance(CreationFactory.java:168)
[catch] at org.netbeans.modules.form.BeanSupport.createBeanInstance(BeanSupport.java:83)
at org.netbeans.modules.form.BeanSupport.getDefaultInstance(BeanSupport.java:109)
at org.netbeans.modules.form.GandalfPersistenceManager.restoreComponent(GandalfPersistenceManager.java:769)
at org.netbeans.modules.form.GandalfPersistenceManager.loadComponent(GandalfPersistenceManager.java:1007)
at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:527)
at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:299)
at org.netbeans.modules.form.FormEditor$3.run(FormEditor.java:337)
at org.netbeans.modules.form.FormLAF$2.run(FormLAF.java:293)
at org.openide.util.Mutex.doEventAccess(Mutex.java:1361)
at org.openide.util.Mutex.readAccess(Mutex.java:320)
at org.netbeans.modules.form.FormLAF.executeWithLookAndFeel(FormLAF.java:276)
at org.netbeans.modules.form.FormEditor.loadFormData(FormEditor.java:334)
at org.netbeans.modules.form.FormEditor.loadFormDesigner(FormEditor.java:232)
at org.netbeans.modules.form.FormDesigner.finishComponentShowing(FormDesigner.java:1932)
at org.netbeans.modules.form.FormDesigner.access$1100(FormDesigner.java:107)
at org.netbeans.modules.form.FormDesigner$PreLoadTask$1.run(FormDesigner.java:1897)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:602)
at java.awt.EventQueue$1.run(EventQueue.java:600)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:148)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
INFO
org.openide.ErrorManager$AnnException: msg
at org.openide.ErrorManager$AnnException.findOrCreate(ErrorManager.java:866)
at org.openide.ErrorManager$DelegatingErrorManager.annotate(ErrorManager.java:653)
at org.netbeans.modules.form.GandalfPersistenceManager.annotateException(GandalfPersistenceManager.java:237)
at org.netbeans.modules.form.GandalfPersistenceManager.annotateException(GandalfPersistenceManager.java:247)
at org.netbeans.modules.form.GandalfPersistenceManager.restoreComponent(GandalfPersistenceManager.java:865)
at org.netbeans.modules.form.GandalfPersistenceManager.loadComponent(GandalfPersistenceManager.java:1007)
at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:527)
at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:299)
at org.netbeans.modules.form.FormEditor$3.run(FormEditor.java:337)
at org.netbeans.modules.form.FormLAF$2.run(FormLAF.java:293)
at org.openide.util.Mutex.doEventAccess(Mutex.java:1361)
at org.openide.util.Mutex.readAccess(Mutex.java:320)
at org.netbeans.modules.form.FormLAF.executeWithLookAndFeel(FormLAF.java:276)
at org.netbeans.modules.form.FormEditor.loadFormData(FormEditor.java:334)
at org.netbeans.modules.form.FormEditor.loadFormDesigner(FormEditor.java:232)
at org.netbeans.modules.form.FormDesigner.finishComponentShowing(FormDesigner.java:1932)
at org.netbeans.modules.form.FormDesigner.access$1100(FormDesigner.java:107)
at org.netbeans.modules.form.FormDesigner$PreLoadTask$1.run(FormDesigner.java:1897)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:602)
at java.awt.EventQueue$1.run(EventQueue.java:600)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:148)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
msg
Caused: java.lang.NullPointerException
at org.statec.ide.ui.components.EnterprisePicker.addPropertyChangeListener(EnterprisePicker.java:654)
at javax.swing.plaf.synth.SynthPanelUI.installListeners(SynthPanelUI.java:49)
at javax.swing.plaf.synth.SynthPanelUI.installUI(SynthPanelUI.java:38)
at javax.swing.JComponent.setUI(JComponent.java:662)
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 org.statec.ide.ui.components.EnterprisePicker.<init>(EnterprisePicker.java:39)
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:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.netbeans.modules.form.CreationFactory.createDefaultInstance(CreationFactory.java:168)
at org.netbeans.modules.form.RADComponent.createBeanInstance(RADComponent.java:252)
at org.netbeans.modules.form.RADComponent.initInstance(RADComponent.java:191)
at org.netbeans.modules.form.GandalfPersistenceManager.restoreComponent(GandalfPersistenceManager.java:851)
at org.netbeans.modules.form.GandalfPersistenceManager.loadComponent(GandalfPersistenceManager.java:1007)
at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:527)
at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:299)
at org.netbeans.modules.form.FormEditor$3.run(FormEditor.java:337)
at org.netbeans.modules.form.FormLAF$2.run(FormLAF.java:293)
at org.openide.util.Mutex.doEventAccess(Mutex.java:1361)
at org.openide.util.Mutex.readAccess(Mutex.java:320)
at org.netbeans.modules.form.FormLAF.executeWithLookAndFeel(FormLAF.java:276)
at org.netbeans.modules.form.FormEditor.loadFormData(FormEditor.java:334)
[catch] at org.netbeans.modules.form.FormEditor.loadFormDesigner(FormEditor.java:232)
at org.netbeans.modules.form.FormDesigner.finishComponentShowing(FormDesigner.java:1932)
at org.netbeans.modules.form.FormDesigner.access$1100(FormDesigner.java:107)
at org.netbeans.modules.form.FormDesigner$PreLoadTask$1.run(FormDesigner.java:1897)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:602)
at java.awt.EventQueue$1.run(EventQueue.java:600)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:148)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Error in loading component: [JDialog]->enterprisePicker1
Cannot create instance of org.statec.ide.ui.components.EnterprisePicker.
The component cannot be loaded.
And for reference:
malbert@dredg:~/.netbeans/7.0/var/log$ java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)
malbert@dredg:~/.netbeans/7.0/var/log$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=11.04
DISTRIB_CODENAME=natty
DISTRIB_DESCRIPTION="Ubuntu 11.04"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是猜测,但问题可能是在某些超类
addPropertyChangeListener(...)
的初始化期间被调用(javax.swing.JPanel.
可能是罪魁祸首),因此此调用发生在propertyChangeSupport
初始化之前。实例字段的初始化顺序为:
如果在
JPanel
初始化期间调用addPropertyChangeListener(...)
方法,则它实际上是EnterprisePicker
的重写版本,但EnterprisePicker
的字段尚未初始化。要解决此问题,您需要在该方法中检查
null
并根据需要进行初始化(或调用super.addPropertyChangeListener(...)
。是否需要拥有自己的实现(添加您自己的PropertyChangeSupport
)?Just a guess, but the problem could be that during initialization of some super class
addPropertyChangeListener(...)
is called (javax.swing.JPanel.<init>
might be the culprit), thus this call happens beforepropertyChangeSupport
is initialized.The initialization sequence of instance fields would be:
If during initialization of
JPanel
theaddPropertyChangeListener(...)
method is called, it would actually be the overridden version ofEnterprisePicker
, butEnterprisePicker
's fields would not have been initialized yet.To fix this you'd check for
null
in that method and initialize as needed (or callsuper.addPropertyChangeListener(...)
. Is there any need to have your own implementation (to add your ownPropertyChangeSupport
)?