Java >
Guidelines Home Page >  Java Look and Feel Design Guidelines
Part II: Fundamental Java Application Design
6: Behavior
  Previous Next Contents/Index/Search

6: Behavior

Users interact with the computer by means of the mouse, the keyboard, and the screen. (Throughout this book, "mouse" refers to any pointing device, including standard mouse devices, trackballs, track pads, and so forth.) Such interaction constitutes the "feel" portion of the Java look and feel.

This chapter describes mouse operations, pointers, and drag-and-drop operations. It discusses keyboard operations, including the use of keyboard focus, keyboard shortcuts, and mnemonics in Java look and feel applications. It also offers guidance on how to provide feedback regarding application progress or status.

Mouse Operations

In Java look and feel applications, the following common mouse operations are available to users:

  • Moving the mouse changes the position of the onscreen pointer (often called the "cursor").
  • Clicking (pressing and releasing a mouse button) selects or activates the object beneath the pointer. The object is usually highlighted when the mouse button is pressed and then selected or activated when the mouse button is released. For example, users click to activate a command button, to select an item from a list, or to set an insertion point in a text area.
  • Double-clicking (clicking a mouse button twice in rapid succession without moving the mouse) is used to select larger units (for example, to select a word in a text field) or to select and open an object.
  • Triple-clicking (clicking a mouse button three times in rapid succession without moving the mouse) is used to select even larger units (for instance, to select an entire line in a text field).
  • Pressing (holding down a mouse button) is used to display drop-down menus, including those marked by menu indicators on buttons.
  • Dragging (pressing a mouse button, moving the mouse, and releasing the mouse button) is used to select a range of objects, to choose items from drop-down or contextual menus, or to move objects in the interface. For example, users drag to select a range of text in a document.

  In your design, assume a two-button mouse. Use mouse button 1 (usually the left button) for selection, activation of components, dragging, and the display of drop-down menus. Use mouse button 2 (usually the right button) to display contextual menus. Do not use the middle mouse button; it is not available on most target platforms.

  Provide keyboard equivalents for all mouse operations, including multiple selections.

  Be aware that Macintosh systems usually have a one-button mouse, other personal computers and network computers usually have a two-button mouse, and UNIX systems usually have a three-button mouse. Macintosh users can simulate mouse button 2 by holding down the Control key while mousing.

The following figure shows the relative placement of mouse buttons 1 and 2 on Macintosh, PC, and UNIX mouse devices.

Figure 67   Mouse Buttons and Their Default Assignments

Default Mouse Button Assignments

Pointer Feedback

The pointer can assume a variety of shapes. For instance, in a text-editing application, the pointer might assume an I-beam shape (called a "text pointer" in the Java 2 platform) to indicate where the insertion point will be if the user presses the mouse button. The insertion point is the location where typed text or a dragged or pasted selection will appear. When the pointer moves out of the editor pane, its appearance changes in accordance with the new component the pointer rests over.

The Java look and feel defines a set of pointer types that map to the corresponding native platform pointers; therefore, the appearance of pointers can vary from platform to platform, as shown in the following table. When no corresponding pointer exists in the native platform toolkit, the pointer is supplied by the JFC.


Pointer Macintosh MIcrosoft Windows CDE Usage in Java Look and Feel Applications
Default Macintosh pointer
Default Microsoft Windows pointer
Default CDE pointer
Pointing or selecting
Macintosh Crosshair pointer
Microsoft Windows Crosshair pointer
CDE Crosshair pointer
Interacting with graphic objects
Macintosh Hand pointer
Microsoft Windows Hand pointer
CDE Hand pointer
Panning objects by direct manipulation
Macintosh Move pointer
Microsoft Windows Move pointer
CDE Move pointer
Moving objects
Macintosh Text pointer
Microsoft Windows Text pointer
CDE Text pointer
Selecting or inserting text
Macintosh wait pointer
Microsoft Windows wait pointer
CDE wait pointer
Indicating that an operation is in progress and the user cannot do other tasks
N Resize
Macintosh north resize pointer
Microsoft Windows north resize pointer
CDE north resize pointer
Adjusting the upper (northern) border of an object
S Resize
Macintosh south resize pointer
Microsoft Windows south resize pointer
CDE south resize pointer
Adjusting the lower (southern) border of an object
E Resize
Macintosh east resize pointer
Microsoft Windows east resize pointer
CDE east resize pointer
Adjusting the right (eastern) border of an object
W Resize
Macintosh west resize pointer
Microsoft Windows west resize pointer
CDE west resize pointer
Adjusting the left (western) border of an object
NW Resize
Macintosh northwest resize pointer
Microsoft Windows northwest resize pointer
CDE northwest resize pointer
Adjusting the upper-left (northwest) corner of an object
NE Resize
Macintosh northeast resize pointer
Microsoft Windows northeast resize pointer
CDE northeast resize pointer
Adjusting the upper-right (northeast) corner of an object
SE Resize
Macintosh southeast resize pointer
Microsoft Windows southeast resize pointer
CDE southeast resize pointer
Adjusting the lower-right (southeast) corner of an object
SW Resize
Macintosh southwest resize pointer
Microsoft Windows southwest resize pointer
CDE southwest resize pointer
Adjusting the lower-left (southwest) corner of an object

  In addition to the shapes in Table 6, a pointer graphic can be defined as an image and created using Toolkit.createCustomCursor if you are using the Java 2 platform.

Mouse-over Feedback

Mouse-over feedback is a visual effect that occurs when users move the pointer over an area of an application window without pressing the mouse button.

In the Java look and feel, mouse-over feedback can be used to show borders on toolbar buttons when the pointer moves over them. A slightly different effect is used to display tool tips. For details, see Toolbars and Tool Tips.

Clicking and Selecting Objects

In the JFC, the selection of objects with the mouse is similar to the standard practice for other graphical user interfaces. Users select an object by clicking it. Clicking an unselected object also deselects any previous selection.

  Follow the general JFC-provided rules for text selection:

  • A single click deselects any existing selection and sets the insertion point.
  • A double click on a word deselects any existing selection and selects the word.
  • A triple click in a line of text deselects any existing selection and selects the line.
  • A Shift-click extends a selection using the same units as the previous selection (character, word, line, and so forth).
  • Dragging (that is, moving the mouse while holding down mouse button 1) through a range of text deselects any existing selection and selects the range.

  Follow the general JFC-provided rules for selection in selectable lists and tables:

  • A click on an object deselects any existing selection and selects the object.
  • A Shift-click on an object extends the selection from the most recently selected object to the current object.
  • A Control-click on an object toggles its selection without affecting the selection of any other objects. This operation can result in disjoint selections.

Displaying Contextual Menus

It can be difficult for users to find and access desired features given all the commands in the menus and submenus of a complex application. Contextual menus (sometimes called "pop-up menus") enable you to make functions easily accessible by associating them with appropriate objects.

Users can open contextual menus in two ways:

  • To pull down the menu, users can press and hold mouse button 2 over a relevant object. Then they can drag to the desired menu item and release the mouse button to choose the item.
  • To post the menu (that is, to pull down the menu and leave it open), users can click mouse button 2 over a relevant object. Then they can click the desired menu item to choose it. The menu is dismissed when a menu item is chosen or the area outside the menu is clicked.

 Click here to view the corresponding code for Figure 68 (also available on the book's companion CD-ROM).

Figure 68   Contextual Menu for a Text Selection

Contextual Menu

  Because users often have difficulty knowing whether contextual menus are available and what is in them, ensure that the items in your contextual menu also appear in the menu bar or toolbar of the primary windows in your application.

  Users on the Microsoft Windows and UNIX platforms display a contextual menu by clicking or pressing mouse button 2. Macintosh users hold down the Control key while clicking.

Java Look and Feel Design Guidelines, second edition.
Copyright 2001. Sun Microsystems, Inc. All Rights Reserved.
Previous Next Contents/Index/Search
Table 6   Pointer Types Available for the Java 2 Platform 
Left Curve
Java SDKs and Tools
Right Curve
Left Curve
Java Resources
Right Curve
JavaOne Banner Java 8 banner (182)