-
Enhancement
-
Resolution: Duplicate
-
P4
-
1.4.2
-
x86
-
windows_xp
A DESCRIPTION OF THE REQUEST :
JMenuItem should update its tooltip text as soon as it receives a property changed event from a references Action on a change of that action's short description property.
JUSTIFICATION :
Sometimes it is needed to change the short description of an instance of Action, e. g. depending on the currently selected object of some application. Unfortunately, JMenuItem ignores this notification, so the tooltip of the menu never changes with updates of the short description of the action.
Actually this mechanism works well for the Mnemonic and Text and the Enabled flag of the Action, but not the tooltip (i. e. not for the shortdescription update notification, since this case is missing in the notification handler inside of JMenuItem).
The changes would be correct in any way, it is not a problematic code change, it is easy and fast to implement, and it would enable this often needed use case.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Action.setValue(SHORTDESCRIPTION, newValue) has to lead to JMenuItem.setTooltip(newValue), which can be done easily in JMenuItem's notification handler.
ACTUAL -
JMenuItem currently ignores changes of the SHORTDESCRIPTION property, while it updates its own properties correctly for enabled, text and mnemonic properties of the linked Action.
---------- BEGIN SOURCE ----------
Action a = new Action() {...}
JMenuItem m = new JMenuItem(a);
a.setValue(SHORTDESCRIPTION, "Does something");
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The action has to be removed from the menuitem by menuitem.setAction(null), after that the action has to be re-linked by menuitem.setAction(myAction) -- since JMenuItem's setAction() implementation checks for equality of new and old action the setAction(null) is needed; also the menuitem's internal method for re-reading all properties from an action is protected and cannot be called from non-descendants. This is not a good workaround, since the calling code needs to know what menuitem actually is linked with what action, what results in a measurable overhead in code lines.
###@###.### 10/21/04 17:32 GMT
JMenuItem should update its tooltip text as soon as it receives a property changed event from a references Action on a change of that action's short description property.
JUSTIFICATION :
Sometimes it is needed to change the short description of an instance of Action, e. g. depending on the currently selected object of some application. Unfortunately, JMenuItem ignores this notification, so the tooltip of the menu never changes with updates of the short description of the action.
Actually this mechanism works well for the Mnemonic and Text and the Enabled flag of the Action, but not the tooltip (i. e. not for the shortdescription update notification, since this case is missing in the notification handler inside of JMenuItem).
The changes would be correct in any way, it is not a problematic code change, it is easy and fast to implement, and it would enable this often needed use case.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Action.setValue(SHORTDESCRIPTION, newValue) has to lead to JMenuItem.setTooltip(newValue), which can be done easily in JMenuItem's notification handler.
ACTUAL -
JMenuItem currently ignores changes of the SHORTDESCRIPTION property, while it updates its own properties correctly for enabled, text and mnemonic properties of the linked Action.
---------- BEGIN SOURCE ----------
Action a = new Action() {...}
JMenuItem m = new JMenuItem(a);
a.setValue(SHORTDESCRIPTION, "Does something");
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The action has to be removed from the menuitem by menuitem.setAction(null), after that the action has to be re-linked by menuitem.setAction(myAction) -- since JMenuItem's setAction() implementation checks for equality of new and old action the setAction(null) is needed; also the menuitem's internal method for re-reading all properties from an action is protected and cannot be called from non-descendants. This is not a good workaround, since the calling code needs to know what menuitem actually is linked with what action, what results in a measurable overhead in code lines.
###@###.### 10/21/04 17:32 GMT
- duplicates
-
JDK-4839464 Shortcoming in the way JMenuItem handles 'propertyChange()' events.
- Resolved