JDK-8202258 : JPopupMenu is inadvertently shown when using setComponentPopupMenu when mouse is dragged from one component to another
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8,9,10,11
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: linux_ubuntu
  • CPU: x86
  • Submitted: 2018-04-25
  • Updated: 2018-09-05
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.
Other
tbdUnresolved
Related Reports
Cloners :  
Description
FULL PRODUCT VERSION :
ubuntu 16.04 

A DESCRIPTION OF THE PROBLEM :
I am seeing an issue when using setComponentPopupMenu.

When you use setComponentPopupMenu in a window and create a modeless dialog and position that over that window, then when mouse is dragged with the left button pressed, to the modeless dialog from the parent window,  and then the right button is immediately  pressed,
then the popup is fleetingly shown.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Run the test program
- Want until the modeless dialog is shown on top of the main frame.
- Make sure the main frame has the focus
- Drag mouse with left button pressed and when the mouse is in modeless dialog, immediately press right button.
- The JPopupMenu that was installed on the main frame's root pane is shown fleetingly.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The JPopupMenu that was installed on the main frame's root pane should not be shown
ACTUAL -
The JPopupMenu that was installed on the main frame's root pane is shown

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;

public class ComponentPopupMenuTest {
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				test();
			}
		});
	}

	private static void test() {
		JPopupMenu popupMenu = new JPopupMenu();
		popupMenu.add(new JMenuItem("You should not see me"));

		JFrame frame = new JFrame("Main Frame");
		frame.getRootPane().setComponentPopupMenu(popupMenu);
		frame.setSize(400, 400);
		frame.setLocation(0, 0);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);

		JTextArea info = new JTextArea("Do a contextual mouse click here while the Main Frame is active");
		info.setWrapStyleWord(true);
		info.setLineWrap(true);

		JDialog dialog = new JDialog(frame, "Modeless Dialog", false);
		dialog.getContentPane().add(info);
		dialog.setSize(300, 300);
		dialog.setLocation(50, 50);
		dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		dialog.setVisible(true);

		frame.toFront();
	}
}

---------- END SOURCE ----------