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.
When adding a personal class file to the component palette and later wants to add it into a form (in GUI-Editor), a java.lang.NullPointerException occurs. >----- Error Message -----< Wed Sep 05 10:32:41 CEST 2001: java.lang.NullPointerException: null java.lang.NullPointerException at org.netbeans.modules.form.RADVisualContainer.initLayoutSupport (RADVisualContainer.java:48) at org.netbeans.modules.form.HandleLayer.addVisualBean (HandleLayer.java:436) at org.netbeans.modules.form.HandleLayer.access$1800 (HandleLayer.java:43) at org.netbeans.modules.form.HandleLayer$HandleLayerMouseListener.mousePressed (HandleLayer.java:904) at java.awt.Component.processMouseEvent(Component.java:3712) at java.awt.Component.processEvent(Component.java:3544) at java.awt.Container.processEvent(Container.java:1164) at java.awt.Component.dispatchEventImpl(Component.java:2593) at java.awt.Container.dispatchEventImpl(Container.java:1213) at java.awt.Component.dispatchEvent(Component.java:2497) at java.awt.LightweightDispatcher.retargetMouseEvent (Container.java:2451) [catch] at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2210) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125) at java.awt.Container.dispatchEventImpl(Container.java:1200) at java.awt.Window.dispatchEventImpl(Window.java:914) at java.awt.Component.dispatchEvent(Component.java:2497) at java.awt.EventQueue.dispatchEvent(EventQueue.java:339) at java.awt.EventDispatchThread.pumpOneEventForHierarchy (EventDispatchThread.java:131) at java.awt.EventDispatchThread.pumpEventsForHierarchy (EventDispatchThread.java:98) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:85) >----- /Error Message -----<
This looks like form editor problem. Reassign if I am wrong.
additional information: if you just add your class-file, all is okay... the auto-generated code looks like eg: drawPanel1 = new com.medianetcom.schedulermonitor.DrawPanel(); I just edited an option at the properties-menu (submenu "Code Generation") the field "Custom Creation Code": new com.medianetcom.schedulermonitor.DrawPanel(this); after this, everything seems to be fine. but after a view starts the class disappears and every try to add it again results in the Exception described above.
Please, what does it mean: > ... after a view starts the class disappears ... ??
Bad english, i know. I built an applet and added the public class (DrawPanel) into a jScrollPane. After a view runs of the program the class DrawPanel is deleted in both GUI-Editor and the file-system-diagram. When trying to readd it, the error appears.
not "a view runs" but "a few runs"
DrawPanel class must be accessible if you want to add it to the form. If the there is not the class then it cannot work. I wonder how it could be deleted (disappeared)? Didn't you make some changes in it, or invoke some "Clean All" or "Compile All" action on the package? I don't know how else could it be deleted...
I made a "build"... and i added something. But why i can't add it to the form again?
I don't know. Does this problem - that DrawPanel can be added to the form, but not again later - does it happen without restarting the IDE meanwhile? Please try in Tools | Option -> Component Palette -> DrawPanel to set property "isContainer" to false. And run IDE with the following flag: runide -J-Dnetbeans.debug.exceptions=true Maybe we'll see more then...
It's independent wheter NetBeans has been restarted or not... When I set isContainer = false I can add it to the form again. But when I try tu change the properties with a right-Click to the component, another NullPointerException occurs. I sent you the debug output by mail.
Thanks for the log. Now I have a question: Is the DrawPanel even JavaBean? I.e. does it have an empty public constructor? If the answer is yes, could you send it to me so I could reproduce somehow what's happening?
The constructor is not empty but public... i will send you this file via email.
Well, that's it - the class MUST have an empty public constructor. Otherwise, it is not possible to create an instance of it, not even to add it to the form. This is an essential request on JavaBeans. So please create an empy public constructor for the DrawPanel which enables using it for visual design. You may left the custom creation code, which takes effect at runtime. Let me know if it helps. But this is also a problem in NetBeans (Form Editor) - there is no notification of "illegal" beans, moreover even no failure detection in this case. I thought this worked... :-(( This will be definitely fixed in NB 3.3. See also issue 14223. I'm marking this issue as INVALID - as the problem is not caused by Form Editor.
I worked another variant like to told me earlier... I set this isContainer value to false and added my public code by using the component inspector... I told you if I right-click to the exploreritem of the drawPanel a NullPointerException occurs. Using the Object Browser has very interesting effects. All values of the property-submenu (background, border, foreground, tooltexttip in "Properties" and actionMap, alignmentX and so on in "Other Properties") are "<java.lang.NullPointerException>"... but adding your personal code has the desired results... bug or feature? I sent you a screenshot via mail.
These NPEs are caused by the fact that there is no instance of the bean - because it cannot be created without public empty constructor. The only bug in the IDE is that it lets you get so far - you should not be able to use such a bean at all. Again - see issue 14223.
*** Issue 19534 has been marked as a duplicate of this issue. ***
Resolved for 3.3.x or earlier, no new info since then -> closing.