提交 4020268f 编写于 作者: P pchelko

8024329: [macosx] JRadioButtonMenuItem behaves like a checkbox when using the ScreenMenuBar

Reviewed-by: anthony, serb
上级 069bb731
...@@ -93,9 +93,9 @@ final class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionLis ...@@ -93,9 +93,9 @@ final class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionLis
} }
if (fMenuItem instanceof JCheckBoxMenuItem) { if (fMenuItem instanceof JCheckBoxMenuItem) {
setState(((JCheckBoxMenuItem)fMenuItem).isSelected()); forceSetState(fMenuItem.isSelected());
} else { } else {
setState(fMenuItem.getModel().isSelected()); forceSetState(fMenuItem.getModel().isSelected());
} }
} }
...@@ -196,10 +196,10 @@ final class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionLis ...@@ -196,10 +196,10 @@ final class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionLis
switch (e.getStateChange()) { switch (e.getStateChange()) {
case ItemEvent.SELECTED: case ItemEvent.SELECTED:
setState(true); forceSetState(true);
break; break;
case ItemEvent.DESELECTED: case ItemEvent.DESELECTED:
setState(false); forceSetState(false);
break; break;
} }
} }
...@@ -210,4 +210,20 @@ final class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionLis ...@@ -210,4 +210,20 @@ final class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionLis
((CCheckboxMenuItem)peer).setIsIndeterminate(indeterminate); ((CCheckboxMenuItem)peer).setIsIndeterminate(indeterminate);
} }
} }
/*
* The CCheckboxMenuItem peer is calling setState unconditionally every time user clicks the menu
* However for Swing controls in the screen menu bar it is wrong - the state should be changed only
* in response to the ITEM_STATE_CHANGED event. So the setState is overridden to no-op and all the
* correct state changes are made with forceSetState
*/
@Override
public synchronized void setState(boolean b) {
// No Op
}
private void forceSetState(boolean b) {
super.setState(b);
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册