在Netbeans中加载自定义JPanel时出现问题。无法使用设计视图

时间:2011-03-14 01:42:49

标签: java netbeans jpanel

所以我一直在使用Netbeans创建一个应用程序。有一段时间一切都很好然后一分钟我可以设计我的观点,然后下一个我不能。错误说

  

加载组件时出错:   [JFrame的] - GT; jSplitPanel1-> scatterPlotView1   无法创建实例   homework3.ScatterPlotView   组件无法加载。

我一直在寻找论坛和网络,但找不到解决这个问题的方法。当我从Update 23更新到Java SE 6 Update 24时,这首先开始发生。我甚至卸载了x86和x64 sdks,然后重新安装。我还卸载了netbeans,重新安装它,然后打开了项目。这工作了一段时间,然后发生了一些黑魔法,现在我回到正方形。

非常感谢任何帮助。

如果有帮助,这是IDE日志中的错误:

Caused: java.lang.InstantiationException: homework3.ScatterPlotView
        at java.lang.Class.newInstance0(Class.java:340)
        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:247)
        at org.netbeans.modules.form.RADComponent.initInstance(RADComponent.java:186)
        at org.netbeans.modules.form.GandalfPersistenceManager.restoreComponent(GandalfPersistenceManager.java:850)
        at org.netbeans.modules.form.GandalfPersistenceManager.loadComponent(GandalfPersistenceManager.java:1006)
        at org.netbeans.modules.form.GandalfPersistenceManager.restoreComponent(GandalfPersistenceManager.java:872)
        at org.netbeans.modules.form.GandalfPersistenceManager.loadComponent(GandalfPersistenceManager.java:1006)
        at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:526)
        at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:298)
        at org.netbeans.modules.form.FormEditor$3.run(FormEditor.java:336)
        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:333)
        at org.netbeans.modules.form.FormEditor.loadFormDesigner(FormEditor.java:231)
        at org.netbeans.modules.form.FormDesigner.finishComponentShowing(FormDesigner.java:1897)
        at org.netbeans.modules.form.FormDesigner.access$1100(FormDesigner.java:107)
        at org.netbeans.modules.form.FormDesigner$PreLoadTask$1.run(FormDesigner.java:1862)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642)
        at java.awt.EventQueue.access$000(EventQueue.java:85)
        at java.awt.EventQueue$1.run(EventQueue.java:603)
        at java.awt.EventQueue$1.run(EventQueue.java:601)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:612)
        at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:137)
        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)
[catch] at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Error in loading component: [JFrame]->jSplitPane1->scatterPlotView1
Cannot create instance of homework3.ScatterPlotView.
The component cannot be loaded.
INFO [org.netbeans.modules.form]: Reinstalling ComponentUI after interrupted serialization of component: javax.swing.JViewport[,0,0,0x0,invalid,layout=javax.swing.ViewportLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=25165832,maximumSize=,minimumSize=,preferredSize=,isViewSizeSet=false,lastPaintPosition=,scrollUnderway=false]
INFO [org.netbeans.modules.form]: Reinstalling ComponentUI after interrupted serialization of component: javax.swing.table.JTableHeader[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=16777544,maximumSize=,minimumSize=,preferredSize=,draggedDistance=0,reorderingAllowed=true,resizingAllowed=true,updateTableInRealTime=true]

1 个答案:

答案 0 :(得分:3)

我过去遇到了同样(或非常接近)的问题。要修复它,我必须提供一个没有参数的构造函数。否则,Designer无法实例化您的类......

希望有所帮助。