Problem loading custom JPanel in Netbeans. Can't use Design view
So I have been creating an application using Netbeans. For a while everything was fine then one minute I could Design my view, then the next I couldn't. The error says
Error in loading component: [JFrame]->jSplitPanel1->scatterPlotView1 Cannot create instance of homework3.ScatterPlo开发者_如何转开发tView The component cannot be loaded.
I have been looking on the forums and the net but cannot find a solution to this problem. This first started happening when I updated to Java SE 6 Update 24 from Update 23. I even uninstalled both x86 and x64 sdks and then reinstalled. I also uninstalled netbeans, re-installed it, then opened the project. This worked for a bit then some black magic happened, and now I am back a square one.
Any help would be greatly appreciated.
Here is the error from the IDE Log if it helps:
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]
I faced the same (or very near) problem in the past. To fix it, I have had to provide a Constructor without arguments. Otherwise, the Designer can't instantiate your Class...
Hope it help.
精彩评论