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.

Bug 222867 - (Build 201207171143) renaming JMenu child components deletes JMenu actions, leaves event handlers
Summary: (Build 201207171143) renaming JMenu child components deletes JMenu actions, l...
Status: RESOLVED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.2
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-27 23:32 UTC by Eric_Balingit
Modified: 2012-12-04 03:19 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
project where issue is reproducible and consistent (252.55 KB, application/x-zip-compressed)
2012-11-28 16:28 UTC, Eric_Balingit
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric_Balingit 2012-11-27 23:32:24 UTC
Product Version: NetBeans IDE 7.2 (Build 201207171143)
Java: 1.7.0_06; Java HotSpot(TM) 64-Bit Server VM 23.2-b09
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
User directory: C:\Users\Eric Balingit\AppData\Roaming\NetBeans\7.2
Cache directory: C:\Users\Eric Balingit\AppData\Local\NetBeans\Cache\7.2

The above is pasted from my 'about' section.

My cpu is actually an i7, not amd64.

I do not know if this is a bug or a consequence of safe re-factoring. When I change a JMenuItem 'Variable Name' in the [Component]-Properties window 'Code' tab, the parent JMenu's adapter and action overrides are dropped from initComponents(), but the handlers are left 'unused'.  This occurs whether there is any reference to the child component(s) in the handlers or not.

The unused handlers are now read-only and can only be safely deleted and redefined.

Steps to reproduce:
create a new java application
add a JFrame Form
add a JMenuBar to the form
add a JMenu to the menu bar named 'parentMenu'
add a JMenu to parentMenu called 'childMenu'
add some JMenuItems to childMenu
select childMenu
select the 'Events' tab in the [childMenu]-Properties window
define a couple of events for childMenu so code for adapter(s) and/or action(s) is generated
change the name of one of the JMenuItems in childMenu
adapter(s) or action(s) are no longer added to childMenu, however, the event handlers are still present in the code body and are squiggly marked as 'unused'.

I have not attempted to produce the same behavior when dealing with parentMenu.

The other JMenuItems in childMenu are not affected.
Comment 1 Tomas Pavek 2012-11-28 10:36:22 UTC
It is strange that changing a name of a component would remove events of another component. I'm not able to reproduce it following your steps, and have no idea what could cause the described behavior.

I guess there must be something special in your setup or steps. Could you create a GUI form sample where it can be reproduced and attach it here? I.e. attach both form and java file and describe which component to rename to what name exactly. Thanks.
Comment 2 Eric_Balingit 2012-11-28 16:28:26 UTC
Created attachment 128525 [details]
project where issue is reproducible and consistent
Comment 3 Eric_Balingit 2012-11-28 16:33:04 UTC
Sorry, my comment did not make it into the reply.

To reproduce the behavior:
Change the name of any jmenuitem in the edit > find... jmenu
the actions of the find... menu disappear, but the handlers stay put

(In reply to comment #2)
> Created attachment 128525 [details]
> project where issue is reproducible and consistent
Comment 4 Eric_Balingit 2012-11-28 16:46:16 UTC
Correction:
The handlers can either be deleted and redefined, or they can be reused as they are, but the actions that lead to them need to be redefined.
Comment 5 Eric_Balingit 2012-11-28 16:54:40 UTC
Another thing that occurred to me is that code generation for both the edit menu and the find menu is serialized.  I do not know if that helps or how it affects the code generation or the refactoring, but that was my first thought when I got your response.

I tried changing the code-gen to serialize when attempting to reproduce the issue from scratch, but that did not cause the behavior.

I hope it works for you with the project!
Comment 6 Tomas Pavek 2012-12-03 14:19:59 UTC
The cause of the problem is in the serialized components, i.e. there is a bug that events for serialized components are not loaded. I've fixed that.
http://hg.netbeans.org/jet-main/rev/3af5e51df393

Please don't set the serialization option for the components unless you have a real special reason for that. It definitely makes no sense for the UI (Swing) components and is only causing troubles. We'd better disable this option completely, but it's not that easy since it's required by the JavaBeans spec.
Comment 7 Quality Engineering 2012-12-04 03:19:24 UTC
Integrated into 'main-golden', will be available in build *201212040001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/3af5e51df393
User: Tomas Pavek <tpavek@netbeans.org>
Log: #222867: workarounds for serialized components: reloading events and other properties after setting deserialized instance, more robustness to failures