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.
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.
Comments
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
11-11-2019
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.
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.
Related discussion at swing-dev mailing list: http://mail.openjdk.java.net/pipermail/swing-dev/2019-August/009737.html
23-08-2019
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.
27-06-2019
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();
}
});
}
}