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.
Created attachment 115045 [details] Sample Nb Platform project that show the bug Hi, BooleanStateAction when referenced from Main Menu in Mac OSX, does not respond on setEnabled(true/false) and setBooleanState(true/false). The problem is only in Mac OSX, in the MS Windows or Linux it is fine. Attached is Sample NB Platform application that indicate the bug note: it is just plain Nb Platform (nothing added), only added BooleanStateAction and TopComponent with button, which show the bug. Just run the above sample - click on the button (on displayed TopComponent) to setEnabled or setChecked the menu - and see the Main Menu, it does not respond at all. Tested on Mac OSX 10.6.2, with default Java that come with it. Nb Platform 7.1 Regards Tonny Kohar
I don't have Mac.
BooleanStateAction.setBooleanState() isn't working on windows either (jdk 1.6). Action.setEnabled() doesn't work on mac but it does work on windows. debugging shows there are no listeners registered to the action instance. so i guess our menu implementation refreshes the appropriate menu item in popup menu listener and the check for checked/unchecked state is missing.
BooleanStateAction is not really the preferred solution for "checkbox" action anymore: ergonomics#d2e57fd4b6d3
The sample application seems to work quite fine on Linux. If you still have problems on Mac, please re-open, I pass to Mac OS X guys again.
Yes, as far as my test go, the bug is still exists on Mac OSX. For me (my own test) the bug does not occur on Linux and MS Windows, it happend only on Mac OSX 10.6.2, with default Java that come with it. note, I am not sure about Mac OSX higher than 10.6.2 because I do not have it. My test is on Mac OSX 10.6.2
Assigning to Tonda. Either he find somebody with Mac or he can buy me one.
Integrated into 'main-golden', will be available in build *201205230300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/d2e57fd4b6d3 User: Jaroslav Tulach <jtulach@netbeans.org> Log: Result of #207477: Offer alternative
how to workaround this bug without modifying Nb codes. This workaround is in user code. The idea is to maintain the JMenuItem reference ourselves and set the appropriate (checked/enabled) state. So you can inherit from WorkaroundBooleanStateAction instead of original BooleanStateAction public abstract class WorkaroundBooleanStateAction extends BooleanStateAction { // if needed do you own stuff /* XXX Netbeans Platform bug 207477 * Workaround for Mac OSX Bug with BooleanStateAction enabled and selected * so keep track JMenuItem ourselves */ private WeakHashMap<JMenuItem, WeakReference<JMenuItem>> menuItemsMap = new WeakHashMap<JMenuItem, WeakReference<JMenuItem>>(); @Override public JMenuItem getMenuPresenter() { if (Utilities.isWindows()) { return super.getMenuPresenter(); } JMenuItem menuItem = super.getMenuPresenter(); menuItemsMap.put(menuItem,new WeakReference<JMenuItem>(menuItem)); return menuItem; } @Override public void setBooleanState(boolean value) { super.setBooleanState(value); if (!Utilities.isWindows()) { for (JMenuItem menuItem : menuItemsMap.keySet()) { menuItem.setSelected(value); } } } @Override public void setEnabled(boolean value) { super.setEnabled(value); if (!Utilities.isWindows()) { for (JMenuItem menuItem : menuItemsMap.keySet()) { menuItem.setEnabled(value); } } } // if needed do you own stuff }