JDK-4644020 : EOU: Hierarchical Menu Behavior - Allow Diagonal Drag
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0,5.0
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_98,windows_xp
  • CPU: x86
  • Submitted: 2002-02-27
  • Updated: 2017-05-23
Related Reports
Duplicate :  
Description
Name: jk109818			Date: 02/27/2002


FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-root-010902-18:51)
Java HotSpot(TM) Client VM (build 1.3.1, mixed mode)


FULL OPERATING SYSTEM VERSION : Windows 98 [Version 4.10.2222]


ADDITIONAL OPERATING SYSTEMS : Mac OS X 10.1.2



A DESCRIPTION OF THE PROBLEM :
When a user pops up a hierarchical menu, she should be able to drag directly to the desired item in that menu.  The shortest path to the desired menu item is usually a diagonal path.
Under Swing, the user must first drag horizontally into the hierarchical menu and then drag down that menu to select the item, otherwise the hierarchical menu closes.  This is very disconcerting behavior for users who are expecting the normal platform behavior (the Mac and Windows allow direct [diagonal] dragging).

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a JMenu topMenu
2. Create another JMenu hMenu and add() it to topMenu
3. Add some JMenuItems to topMenu.
4. Add some JMenuItems (say 6+) to the hMenu
5. Create a test window and menuBar and add topMenu to it
6. Try selecting the last item from hMenu
7. Compare the behavior with native apps in MacOS or Windows

EXPECTED VERSUS ACTUAL BEHAVIOR :
When the user pops up a hierarchical menu, she should be able to drag the pointer directly to the desired menu item.  If you do this in Swing (and the item is not directly across) the hierarchical menu closes.  Native menus allow direct (i.e. diagonal) dragging; they appear to use a timer and/or a screen region to allow this behavior.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Not Applicable.  This is a user interface behavioral bug.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.event.*;
import javax.swing.*;

public class BugDemo extends JFrame {

	public static void main(String args[]) {
		new BugDemo();
	}
	
	
	public BugDemo() {
		super("Swing Hierarchical Menu Bug Demo");
		setSize(500,300);
		setJMenuBar(createMenuBar());
		WindowListener windowCloser = new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		};
		addWindowListener(windowCloser);
		show();
	}


	JMenuBar createMenuBar() {
		JMenuBar menuBar = new JMenuBar();
		JMenu mFile = new JMenu("File");
		mFile.add(createHierachicalMenu());
		mFile.add(new JMenuItem("Test 1"));
		mFile.add(new JMenuItem("Test 2"));
		mFile.add(new JMenuItem("Test 3"));
		mFile.add(new JMenuItem("Test 4"));
		mFile.add(new JMenuItem("Test 5"));
		mFile.add(new JMenuItem("Test 6"));
		menuBar.add(mFile);
		return menuBar;
	}


	JMenu createHierachicalMenu() {
		JMenu mHierachical = new JMenu("Choose Me");
		mHierachical.add(new JMenuItem("Test 7"));
		mHierachical.add(new JMenuItem("Test 8"));
		mHierachical.add(new JMenuItem("Test 9"));
		mHierachical.add(new JMenuItem("Test A"));
		mHierachical.add(new JMenuItem("Test B"));
		mHierachical.add(new JMenuItem("Hi!"));
		return mHierachical;
	}

}
---------- END SOURCE ----------

CUSTOMER WORKAROUND :
None found.
(Review ID: 137732) 
======================================================================

Comments
EVALUATION Name: azR10139 Date: 02/14/2003 The reason of this bug is that we are setting the selectedPath in the MenuSelectionManager immediatelly when mouse pointer enters the menu element and if popup in result of changing of selection path becomes not selected it immediatelly closes. The idea of fix is not to close popup when they became not selected and to raise Timer to close popup some time later. The amount of time will be taken from JMenu by calling getDelay(). If timer is set popup should not close on selection change. Also this fix needs some work with the painting and BasicMenuItemUI.getPath() method must be corrected. Currently this method returns wrong path to the menu item inside a popup that is currently not in selected path. ###@###.### ======================================================================
2004-09-25