| Java >
Guidelines Home Page > Java Look and Feel Design Guidelines >
Part III: The Components of the Java Foundation Classes > 9: Menus and Toolbars >
Contextual menus, sometimes called "pop-up menus," offer only menu items that are applicable or relevant to the object or region at the location of the pointer. The appearance of contextual menus in the Java look and feel is similar to that of drop-down menus, including the display of mnemonics, keyboard shortcuts, and submenus. Contextual menus do not have a menu title.
Click here to view the corresponding code for Figure 139 (also available on the book's companion CD-ROM).
Figure 139 shows a contextual menu offering editing commands.Figure 139 Contextual Menu
Users can display a contextual menu by clicking or pressing mouse button 2 while the pointer is over an object or area that is associated with that menu. (On the Macintosh platform, users click or press the mouse button while holding down the Control key.)
For keyboard operations appropriate to contextual menus, see Table 20.
Ensure that any features you present in contextual menus are also available in more visible and accessible places, such as drop-down menus. Users might not know contextual menus are available, especially if you do not use contextual menus consistently throughout your application.
Display keyboard shortcuts and mnemonics in contextual menus that are consistent with their usage in any corresponding drop-down menus.
If no object is selected when a contextual menu is displayed, select the object under the pointer and display the contextual menu appropriate to that object. For instance, if the object under the pointer is text, display the contextual menu with editing commands.
If the pointer is over an existing selection at the time the user opens the contextual menu, display the menu that is associated with that selection.
If the pointer is not over the currently selected object when the user opens the contextual menu, create a new selection at the point where the user pressed the mouse button. Display the contextual menu that is appropriate to the object that is beneath the pointer.
If the user opens a contextual menu when the pointer is over an area that cannot be selected, such as the background of a container, remove any existing selection and display the contextual menu for the container.
Contextual menus are created using the
|Java Look and Feel Design Guidelines, second edition.
Copyright 2001. Sun Microsystems, Inc. All Rights Reserved.