JDK-8225505 : ctrl-F1 does not show the tooltip of a menu item (JMenuItems)
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u211,11,12,13
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-06-10
  • Updated: 2020-06-01
  • Resolved: 2019-08-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 13 JDK 14 JDK 8 Other
11.0.6-oracleFixed 13.0.2Fixed 14 b13Fixed 8u241Fixed openjdk8u232Fixed
Related Reports
Relates :  
ctrl-F1 does not show the tooltip of a menu item (JMenuItems) 

Pressing ctrl-F1, on the button works correctly, but it doesn't work on the 
menu item. 
Fix request: Backport to 8u is requested because it is a part of 8u241-oracle. Patch does not apply cleanly to 8u. 8u review thread: https://mail.openjdk.java.net/pipermail/jdk8u-dev/2019-November/010586.html 8u webrev: http://cr.openjdk.java.net/~akasko/jdk8u/8225505/webrev.00/ Testing: manual check with included test on linux and windows

Fix request: Backport to 11u is requested because it is a part of 11.0.6-oracle. Patch does not apply cleanly to 11u, the only required change is a year in the copyright header. 11u changeset with corrected year and original attribution: http://cr.openjdk.java.net/~akasko/jdk11u/8225505/8225505_11u.changeset Testing: manual check with included test on linux and windows, JCK.

URL: https://hg.openjdk.java.net/jdk/jdk/rev/e00a2d8a1016 User: psadhukhan Date: 2019-08-29 10:39:05 +0000

Fix Request (13u) - Justification: The changes fix the problems with showing/hiding of tooltip message for a menu element/item when CTRL + F1 combination is used. - Risk Analysis: Low, small changes in ToolTipManager class - Testing: The fix may be verified using the regression test included into the change set The patch from jdk-dev (14) applies cleanly to 13u.

URL: https://hg.openjdk.java.net/jdk/client/rev/e00a2d8a1016 User: dmarkov Date: 2019-08-23 13:26:27 +0000

Related discussion at swing-dev mailing list: http://mail.openjdk.java.net/pipermail/swing-dev/2019-August/009737.html

Problem description: When tool tip is set for JMenuItem ToolTipManger registers a special key listener for this item. The listener is intended for processing tool tip key bindings, (i.e CTRL + F1) and show or hide tool tip message. However BasicPopupMenuUI.MenuKeyboardHelper handles all key events for menu elements. In other words a menu element such as JMenuItem does not handle a key event directly. As a result the tool tip messages, which is set for JMenuItem, cannot be shown using CTRL + F1 combination. Fix: BasicPopupMenuUI.MenuKeyboardHelper should detect tool tip key sequence and forward it to currently highlighted(selected) for further processing.

Test case to reproduce the issue: import java.awt.BorderLayout; import java.awt.Container; import java.awt.EventQueue; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; public class Test { private void display() { JFrame f = new JFrame("Test"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); f.setJMenuBar(menuBar); JMenu menu = new JMenu("Menu"); JMenuItem addItem = new JMenuItem("Item1"); addItem.setToolTipText("Tooltip 1"); menuBar.add(menu); menu.add(addItem); addItem = new JMenuItem("item2"); addItem.setToolTipText("Tooltip 2"); menuBar.add(menu); menu.add(addItem); Container container = f.getContentPane(); container.setLayout(new BorderLayout()); JButton button = new JButton("xxx"); button.setToolTipText("Button Tooltip"); container.add(button, BorderLayout.SOUTH); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); } public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { new Test().display(); } }); } }

The problem is reproducible on JDK 13 as well