JDK-6269335 : Menus does not implement a 500 ms timeout before disappearing.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-05-12
  • Updated: 2011-02-16
  • Resolved: 2005-07-26
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.5.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-rc-b63)
Java HotSpot(TM) Client VM (build 1.5.0-rc-b63, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

But exists probably in all Windows versions.

A DESCRIPTION OF THE PROBLEM :
There is an UI inconsistency in Java/Swing's attempt to mimic Microsoft Windows behavior. Specifically menus in Java have a 500 ms timeout before they disappear. In Java menus disappear immediately after the user's mouse cursor leaves the area of the menus.

To see the bug in effect, run the test case and move the mouse pointer to the horizontal of a sub menu (e.g.pointg at "bM" in "subMenu1"). Now move the mouse
pointer along the DIAGONAL (straight line) to the vertical center of
the sub menu (e.g. towards "subMenuItem3"). You will notice that this
movement is not possible, as soon as the mouse pointer leaves the menu
item that leads to a sub menu, the submenu in question disappears.
This is not the expected behavior in Windows XP, where when the menu
item that leads to a sub menu is exited (by the mouse pointer) there
is a time-out of around 500-1000 ms before the actual sub menu
disappears. This allows users to select sub menus much easier since
you can just flick the mouse to a sub menu without worrying about
being exactly within the menu item at all times. In Java however the
user must move the mouse pointer exactly within the horizontal
"tunnel" of a menu item (e.g. exactly within the JMenuItem boundary of
"subMenu1"). This is both inconsistent and worse behavior than the
behavior on the native platform.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Navigate any menu hierchy in a Java/Swing program and compare with the menu hierchy in for example Mircosoft Word.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Menus disappear with a 500 ms timeout.
ACTUAL -
Menus disappear immediately.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;

public class MenuBug extends JFrame {
	
	private MenuBug() {
		JPanel emptyPanel = new JPanel();
		emptyPanel.setPreferredSize(new Dimension(300,300));
		getContentPane().add(emptyPanel, BorderLayout.CENTER);
		JMenu testMenu = new JMenu("Test menu");
		testMenu.add(new JMenuItem("Item1"));
		JMenu subMenu1 = new JMenu("SubMenu1");
		subMenu1.add(new JMenuItem("SubMenu1Item1"));
		subMenu1.add(new JMenuItem("SubMenu1Item2"));
		subMenu1.add(new JMenuItem("SubMenu1Item3"));
		subMenu1.add(new JMenuItem("SubMenu1Item4"));
		subMenu1.add(new JMenuItem("SubMenu1Item5"));
		testMenu.add(subMenu1);
		testMenu.add(new JMenuItem("Item2"));
		testMenu.add(new JMenuItem("Item3"));
		testMenu.add(new JMenuItem("Item4"));
		JMenu subMenu2 = new JMenu("SubMenu2");
		subMenu2.add(new JMenuItem("SubMenu2Item1"));
		subMenu2.add(new JMenuItem("SubMenu2Item2"));
		subMenu2.add(new JMenuItem("SubMenu2Item3"));
		subMenu2.add(new JMenuItem("SubMenu2Item4"));
		subMenu2.add(new JMenuItem("SubMenu2Item5"));
		testMenu.add(subMenu2);
		testMenu.add(new JMenuItem("Item5"));
		JMenuBar menuBar = new JMenuBar();
		menuBar.add(testMenu);
		setJMenuBar(menuBar);
		pack();
		setLocationRelativeTo(null);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setVisible(true);
	}
	
	public static void main(String[] argv) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				new MenuBug();
			}
		});
	}

}

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


CUSTOMER SUBMITTED WORKAROUND :
Only way I see it is to override the behavior in JMenu, not sure if this will work smoothly though since the MouseListener instance appears to be private.
###@###.### 2005-05-12 12:11:49 GMT

Comments
EVALUATION I definitely agree with this bug report. Swing should make the sub-menu behavior more usable. ###@###.### 2005-05-26 18:52:04 GMT This bug is a duplicate.
26-05-2005