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 172457 - IDE does not load / ignores some properties of exitMenuItem created with Swing Java App. template
Summary: IDE does not load / ignores some properties of exitMenuItem created with Swin...
Status: RESOLVED WONTFIX
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-17 11:36 UTC by xzemanekj
Modified: 2011-09-06 14:48 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description xzemanekj 2009-09-17 11:36:17 UTC
I started project using Swing Java Application template. I changed accelerator (CTRL+K) and mnemonic (K) property of
exitMenuItem (Form-->menuBar[JMenuBar]-->fileMenu[JMenu]-->exitMenuItem[JMenuItem]). It shows in preview and compiles
correctly, also the form file contains correct values, but when I exit the IDE and then start it again, the properties
window of exitMenuItem shows the original values (CTRL+Q, X).
Comment 1 Victor Vasilyev 2009-09-18 00:33:38 UTC
AFAIU this issue is assigned to the wrong component ("properties"), because it has not any relations to the property files. 
Could you please, reassign it to a correct component (may be "form" component)?
Comment 2 xzemanekj 2009-09-18 07:47:48 UTC
Reassigned to FORM component.
Comment 3 Jan Stola 2009-10-06 16:44:47 UTC
Reproducible.
Comment 4 Tomas Pavek 2010-08-20 16:55:05 UTC
Under Swing Application Framework the menu items use actions, so shortcuts, mnemonics, text, icon, etc should be defined for the action (in action property editor).

The action when set ensures the appropriate menu item's properties are set. If the properties are set directly on the menu item, they override those from the action. The code is generated correctly, so action is set first allowing the properties be changed additionally. But when the form is loaded into the GUI builder, it probably sets the action later than the properties, which resets the explicitly set values.

The workaround is to modify the action as described above, the properties should only be set if on some component the presentation should differ from the action definition. It's better to avoid the order-dependent settings (which is against JavaBeans spec).
Comment 5 mj.homeschool 2011-06-09 19:42:58 UTC
I've just encountered this issue, and as it took some figuring out, here's what I discovered:

When setting both an Action AND a Mnemonic on a menu item, be aware that the Properties "mnemomic" setting gets overwritten by what you set in the Action dialog. This also applies to the shortcut, if you set it by double-clicking the "shortcut" space on the visual menu.

What does this mean?
- Your mnemonic and shortcut settings will appear until you close the file, and will be correctly saved in the .form file, but will not appear in the editor next time you re-open the file in the GUI Builder.
- Your mnemonic and shortcut will not appear in the built program.

While this is unfortunate, it does appear to be an intended order of priority, which the GUI Builder simply doesn't account for. (And overwrites later, if you save it after closing and re-opening.)

To get past it:
- When setting the Action, set the shortcut and mnemonic IN the Action dialog.
- To set the shortcut, click in Accelerator > Letter and hit the desired shortcut on the keyboard.
- To set the mnemonic, re-type the MenuItem text in the Text field, placing an ampersand (&) directly before the mnemonic character. ("&File" for "F", "Set N&ame" for "a", etc.)

Ideally, NetBeans GUI Builder will be upgraded to link the MenuItem properties to the Action, OR to disable these properties (with a tooltip indicating to set them in the Action dialog) whenever an Action is assigned.
Comment 6 Jan Stola 2011-09-06 14:48:01 UTC
This bug is specific to Swing Application Framework and support of this technology/library has been discontinued => I am closing this issue as 'will not fix'.