import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import javax.swing.event.MouseInputAdapter;

public class MouseDragPopupBug {

	public static void main(final String[] args) {

		SwingUtilities.invokeLater(() -> {
			final JFrame frame = new JFrame(MouseDragPopupBug.class.getSimpleName());
			frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			frame.getContentPane().addMouseMotionListener(new MouseInputAdapter() {

				@Override
				public void mouseDragged(final MouseEvent e) {
                                      // NOTE: This should print regardless of whether the mouse is inside or outside the JFrame boundary
					System.out.println("MOUSE DRAGGED [" + e + "]");
				}
			});

			final JMenuBar menuBar = new JMenuBar();

			final JMenu fileMenu = new JMenu("File");
			fileMenu.add(new JMenuItem("Open"));

			menuBar.add(fileMenu);

			frame.setJMenuBar(menuBar);

			frame.setSize(500, 500);
			frame.setVisible(true);
		});
	}
}
