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.
Hello, We have developped a subClass of swing.JTable and made it as a Bean. This Bean has been successfully put to the palette window. When adding one instance of this bean to a JFrame form, everything works OK excepted that NetBeans, sets the JTable model as a defaultTableModel with 4 rows and 4 columns. For our particular subclass of JTable the "setModel" should not be called on the table because at instantiation level this is done on the superclass and we don't want NetBeans to overwrite the model after instatiation. So what we have done to avoid this is to override the public void setModel (TableModel tm) inside our class and this method is an empty method in our case. BUT since we have done this, we cannot create anymore any instance of our class with form editor. IDE invites me to issue the problem and the message.log file here attached. Thanks in advance for your help. F. Poncet (Software engineer) message.log : INFORMATIONAL *********** Exception occurred ************ at 7:25 PM on Sep 19, 2007 java.lang.NullPointerException at javax.swing.JTable$AccessibleJTable.<init>(JTable.java:4900) at javax.swing.JTable.getAccessibleContext(JTable.java:4857) at org.netbeans.modules.form.RADVisualComponent.createAccessibilityProperties(RADVisualComponent.java:373) at org.netbeans.modules.form.RADVisualComponent.getPropertyByName(RADVisualComponent.java:174) at org.netbeans.modules.form.RADComponent.getBeanProperty(RADComponent.java:665) at org.netbeans.modules.form.MetaComponentCreator.defaultVisualComponentInit(MetaComponentCreator.java:1411) at org.netbeans.modules.form.MetaComponentCreator.createVisualComponent(MetaComponentCreator.java:816) at org.netbeans.modules.form.MetaComponentCreator.addVisualComponent(MetaComponentCreator.java:739) at org.netbeans.modules.form.MetaComponentCreator.createAndAddComponent2(MetaComponentCreator.java:311) at org.netbeans.modules.form.MetaComponentCreator.access$300(MetaComponentCreator.java:53) at org.netbeans.modules.form.MetaComponentCreator$3.run(MetaComponentCreator.java:280) at org.netbeans.modules.form.FormLAF$1.run(FormLAF.java:64) at org.openide.util.Mutex.doEventAccess(Mutex.java:1178) at org.openide.util.Mutex.readAccess(Mutex.java:259) at org.netbeans.modules.form.FormLAF.executeWithLookAndFeel(FormLAF.java:49) [catch] at org.netbeans.modules.form.MetaComponentCreator.createAndAddComponent(MetaComponentCreator.java:277) at org.netbeans.modules.form.MetaComponentCreator.createComponent(MetaComponentCreator.java:87) at org.netbeans.modules.form.HandleLayer$NewComponentDrag.end(HandleLayer.java:2600) at org.netbeans.modules.form.HandleLayer$ComponentDrag.end(HandleLayer.java:2009) at org.netbeans.modules.form.HandleLayer.endDragging(HandleLayer.java:865) at org.netbeans.modules.form.HandleLayer.mousePressed(HandleLayer.java:1533) at java.awt.Component.processMouseEvent(Component.java:5485) at javax.swing.JComponent.processMouseEvent(JComponent.java:3126) at java.awt.Component.processEvent(Component.java:5253) at java.awt.Container.processEvent(Container.java:1966) at java.awt.Component.dispatchEventImpl(Component.java:3955) at java.awt.Container.dispatchEventImpl(Container.java:2024) at java.awt.Component.dispatchEvent(Component.java:3803) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3889) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822) at java.awt.Container.dispatchEventImpl(Container.java:2010) at java.awt.Window.dispatchEventImpl(Window.java:1778) at java.awt.Component.dispatchEvent(Component.java:3803) at java.awt.EventQueue.dispatchEvent(EventQueue.java:463) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Making setModel method noop in JTable subclass is not a good idea. It prevents any model to be set - the exception indicates that clearly, it happens because the table has no model (JTable when instantiated creates a default model if not provided from outside. So the model should never be null.) You say your class creates a table model we should not try to rewrite. But we only rewrite it if it is a DefaultTableModel with no rows and no column. Is that really what you want - to keep the empty model in the table? Are you sure your table has the right model really set? Could you possibly attach here the code of your table subclass?
Created attachment 49354 [details] MultiScalarTableViewer (Subclass of JTable) source code
Hello, Thanks a lot for your answer to my issue. Yes I am sure that the setModel should not be called on our object (subclass of JTable). In fact the call to setModel leads to the setModel method in JTable class. In our case we have defined our own Class to be used as the model of JTable which itself extends the DefaultTableModel. This is the reason why the model should not be overwritten, since it should be of class "MultiScalarViewerTableModel" in our case. I attach to this issue the source code of our "JTable subclass" which is named "MultiScalarTableViewer.java". Inside this file you can find the definition of the table model "MultiScalarViewerTableModel" class. I have already made a workaround to this problem in my code : private method initAttModels() lines 698 to 709 of the java file attached to this issue. This workaround works fine for the moment for us. Thank you in adavance for your precious help. Faranguiss PONCET (software engineer)
OK, makes sense. Good you have a workaround. I've made a fix - only replace the model if it is DefaultTableModel class directly, not a subclass. Will be in NB 6.0 beta2. /cvs/form/src/org/netbeans/modules/form/MetaComponentCreator.java new revision: 1.115; previous revision: 1.114