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 243270 - Actions.connect fails to update JMenuItem's enabled state in main menu
Summary: Actions.connect fails to update JMenuItem's enabled state in main menu
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Actions (show other bugs)
Version: 8.0
Hardware: PC Mac OS X
: P3 normal with 1 vote (vote)
Assignee: Jan Peska
Depends on:
Reported: 2014-03-25 20:43 UTC by ebakke
Modified: 2014-07-14 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:

An example Action exhibiting the bug (2.01 KB, application/octet-stream)
2014-03-25 20:43 UTC, ebakke

Note You need to log in before you can comment on or make changes to this bug.
Description ebakke 2014-03-25 20:43:35 UTC
Created attachment 146317 [details]
An example Action exhibiting the bug

See the attached example.

Actions.connect(JMenuItem, Action, boolean popup) fails to keep the JMenuItem up to date with the state of the Action in the case where popup == false.

The bug seems to be in Actions.MenuBridge.prepare(), where addNotify() is called only if the "popup" parameter is true, based on the assumption that "popups generally get no hierarchy events" (according to a comment in MenuBridge.prepare() ). This is true, but also seems to be true for items in the main menu. Maybe it's a MacOS thing?

With the above understanding of the bug, a workaround is to do "menuItem.putClientProperty("ancestor", new JMenu("FakeMenu"));" after invoking Actions.connect. But it would be nice to have this fixed in general.

Proposed fix: call addNotify() regardless of the value of popup in Actions.MenuBridge.prepare().

A possibly related bug:
Comment 1 Jan Peska 2014-07-14 09:14:53 UTC
Your example works fine on my Windows 7. I'll try to reproduce it on MacOS as you suggested.