Guidelines Home Page >  Java Look and Feel Design Guidelines
Part III: The Components of the Java Foundation Classes
> 7: Windows and Panes >
Constructing Windows
  Previous Next Contents/Index/Search

Constructing Windows

A primary window, secondary window, utility window, or plain window can serve as a top-level container for interface elements in your application.

Figure 89   Top-Level Containers


Top-Level Containers

  Primary windows are implemented using the JFrame component. Secondary windows and utility windows are implemented using the JDialog component (for dialog boxes and utility windows) or the JOptionPane component (for alert boxes). Plain windows are implemented using the JWindow component.

Primary Windows

Primary windows are provided by the operating system of the platform on which the application is running--for instance, UNIX, Microsoft Windows, OS/2, or Macintosh.

Specifically, you cannot alter the appearance of the window border and title bar, including the window controls that affect the state of a window (for example, the Maximize button in Microsoft Windows title bars). Window behavior, such as resizing, dragging, minimizing, positioning, and layering, is controlled by the operating system.

The content provided by your application, however, takes on the Java look and feel, as shown in Figure 90 (which depicts a MetalEdit document window as it appears on the Microsoft Windows platform).

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

Figure 90   Primary Window on the Microsoft Windows Platform


Primary Window on Microsoft Windows

Typically, when users close or minimize a window, any associated secondary windows are closed as well. However, the operating system does not take care of this behavior automatically for JFC applications.

  Keep track of the secondary windows in your application; close them if the primary window is closed or hide them if their primary window is minimized.

  Although native operating systems typically display a close control on the title bar of windows, provide a Close item or Exit item in your File menu as well.

  In the JFC, primary windows are created using the JFrame component. This component appears with the border, title bar, and window controls of the platform on which it is running. This is the JFC component you are most likely to use as the top-level container for a primary window.

Secondary Windows

Secondary windows (dialog boxes and alert boxes) are displayed in a window supplied by the native operating system. In the JFC, the component for dialog boxes is called JDialog, and the component for alert boxes is JOptionPane. These windows appear with the borders and title bars of the platform on which they are running. Chapter 8 provides more guidelines for the design of dialog boxes and alert boxes.

Figure 91 shows a JFC-supplied Warning alert box for the sample text-editing application, MetalEdit.

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

Figure 91   Alert Box on the Macintosh Platform


Alert Box on Macintosh

Dialog and alert box behavior, such as dragging and closing, is controlled by the native operating system. For keyboard operations that are appropriate to dialog and alert boxes, see Table 23.

  Keep in mind that some platforms do not provide close controls in the title bar for dialog boxes. Always provide a way to close the window in the dialog box or alert box itself.

  The JOptionPane component is used to implement an alert box. If the box supplied by the JFC does not suit your needs, you can use the JDialog component.

Plain Windows

You can create a window that is a blank plain rectangle. The window contains no title bar or window controls, as shown in the following figure. (Note that the black border shown around this plain window is not provided by the JFC.)

Figure 92   Plain Window Used as the Basis for a Splash Screen


Plain Window in Splash Screen

A plain window does not provide dragging, closing, minimizing, or maximizing. You can use a plain window as the container for a splash screen, which appears and disappears without user interaction, as shown in the preceding figure.

  The JWindow component is used to implement plain windows. (The JFrame component is used to implement primary windows.)

Utility Windows

A utility window is often used to display a collection of tools, colors, or patterns. Figure 93 shows a utility window that displays a collection of objects.

Figure 93   Utility Window


Utility Window

Unlike secondary windows, which should close automatically when their associated windows are closed, utility windows should remain open when primary windows are closed.

User choices made in a utility window refer to and affect the active primary window. A utility window remains on screen for an extended period of time while users go back and forth between the utility window and primary windows. In contrast, a secondary window is designed to enable users to resolve an issue in an associated primary window and is usually dismissed once users have resolved the issue.

The same keyboard operations that apply in dialog boxes and alert boxes apply to utility windows. For information on keyboard operations appropriate for utility windows, see Table 14 and Table 23.

  Because utility windows are not dependent on a primary window, do not automatically dismiss utility windows when primary windows are closed.

  Ensure that the same initial focus and keyboard navigation features available in secondary windows are available in utility windows.

  Utility windows in a non-MDI application are implemented using the JDialog component, whereas in an MDI application, internal utility windows are a specific style of the JInternalFrame component. Therefore, internal utility windows can be used only within a backing window. Use the client properties mechanism to set the JInternalFrame.isPalette to true.

Java Look and Feel Design Guidelines, second edition.
Copyright 2001. Sun Microsystems, Inc. All Rights Reserved.
Previous Next Contents/Index/Search
Left Curve
Java SDKs and Tools
Right Curve
Left Curve
Java Resources
Right Curve
Java 8 banner (182)