The guidelines in this book pertain to applications built with the Java 2 SDK, Standard Edition, v. 1.2 (referred to hereafter as "Java 2 SDK"), or the Java Development Kit versions 1.1.3 through 1.1.7 (referred to hereafter as "JDK 1.1"). The Java Foundation Classes are available for use with JDK 1.1, but they are an integral part of the Java 2 platform.
The Java Foundation Classes (JFC) include the Swing classes , which define a complete set of graphic interface components for JFC applications. An extension to the original Abstract Window Toolkit, the JFC includes the Swing classes, pluggable look and feel designs, and the Java Accessibility API, which are all implemented without native code (code that refers to the methods of a specific operating system or is compiled for a specific processor). The JFC components include windows and frames, panels and panes, dialog boxes, menus and toolbars, buttons, sliders, combo boxes, text components, tables, lists, and trees.
All the components have look and feel designs that you can specify. The cross-platform, default look and feel is the Java look and feel . For details on the design principles and visual elements underlying the Java look and feel, see Chapter 1.
In code, the Java look and feel is referred to as "Metal."
The following figure summarizes the differences in the Java Foundation Classes in JDK 1.1 and the Java 2 SDK. Both development kits contain the Abstract Window Toolkit (AWT), the class library that provides the standard application programming interfaces for building graphical user interfaces for Java programs. There is native code in the AWT code in both kits, and in drag and drop and the Java 2D TM API in the Java 2 SDK.
In the Java 2 SDK, the Java Foundation Classes also include the Java 2D API, drag and drop, and other enhancements. The Java 2D API provides an advanced two-dimensional imaging model for complex shapes, text, and images. Features include enhanced font and color support and a single, comprehensive rendering model.
The Java Accessibility API provides ways for an assistive technology to interact and communicate with JFC components. A Java application that fully supports the Java Accessibility API is compatible with technologies such as screen readers and screen magnifiers. A separate package, Java Accessibility Utilities , provides support in locating the objects that implement the Java Accessibility API.
A pluggable look and feel architecture is used to build both visual and nonvisual designs, such as audio and tactile user interfaces. For more on the pluggable look and feel, see Pluggable Look and Feel Architecture.
Keyboard navigation enables users to move between components, open menus, highlight text, and so on. This support makes an application accessible to people who do not use a mouse. For details on keyboard operations, see Appendix A.
JDK 1.1 and the Java 2 SDK provide internationalized text handling. This feature includes support for the bidirectional display of text lines--important for displaying documents that mix languages with a left-to-right text direction (for instance, English, German, or Japanese) and languages with a right-to-left direction (for instance, Arabic or Hebrew). JDK 1.1 and the Java 2 SDK also provide resource bundles, locale-sensitive sorting, and support for localized numbers, dates, times, and messages.
The Java Foundation Classes include Swing, a complete set of user interface components, including windows, dialog boxes, alert boxes, panels and panes, and basic controls. Each JFC component contains a model (the data structure) and a user interface (the presentation and behavior of the component), as shown in the following illustration.
Because both presentation and behavior are separate and replaceable ("pluggable"), you can specify any of several look and feel designs for your application--or you can create your own look and feel. The separation of a component's model (data structure) from its user interface (display and interaction behavior) is the empowering principle behind the pluggable look and feel architecture of the JFC. A single JFC application can present a Java look and feel, a platform-specific look and feel, or a customized interface (for example, an audio interface).
Consider the slider in the following figure as a simplified example. The slider's model contains information about the slider's current value, the minimum and maximum values, and other properties. The slider's user interface determines how users see or interact with the slider. The model knows almost nothing about the user interface--while the user interface knows a great deal about the model.
You can use the client properties mechanism to display an alternate form of a specific Java user interface component. If a look and feel design does not support the property, it ignores the property and displays the component as usual. You can set alternate appearances for sliders, toolbars, trees, and internal frames. For instance, a nonfilling slider is displayed by default. However, by using the client properties mechanism, you can display a filling slider, as shown in Figure 16.
The following table illustrates the major user interface components in the JFC. Components are listed alphabetically by their names in code. Their English names are provided, followed by the location of more detailed information on each component.
|Component||Code Name||Common Name||For Details|
|JButton||Command button and toolbar button|| Click here
|JCheckBoxMenuItem||Checkbox menu item||Click here|
|JColorChooser||Color chooser||Click here|
|JComboBox||Noneditable and editable combo boxes||Click here|
|JDesktopPane||Desktop pane||Click here|
|JDialog||Dialog box, secondary window, and utility window|| Click here
|JEditorPane||Editor pane||Click here|
|JFrame||Primary window||Click here|
|JInternalFrame||Internal frame, minimized internal frame, and palette window|| Click here
|JMenu||Drop-down menu and submenu|| Click here
|JMenuBar||Menu bar||Click here|
|JMenuItem||Menu item||Click here|
|JOptionPane||Alert box||Click here|
|JPasswordField||Password field||Click here|
|JPopupMenu||Contextual menu||Click here|
|JProgressBar||Progress bar||Click here|
|JRadioButton||Radio button||Click here|
|JRadioButtonMenuItem||Radio button menu item||Click here|
|JScrollPane||Scroll pane||Click here|
|JSplitPane||Split pane||Click here|
|JTabbedPane||Tabbed pane||Click here|
|JTextArea||Plain text area||Click here|
|JTextField||Noneditable and editable text fields (single line)||Click here|
|JTextPane||Editor pane with the styled editor kit plug-in||Click here|
|JToggleButton||Toggle button and toolbar button|| Click here
|JToolTip||Tool tip||Click here|
|JTree||Tree view||Click here|
|JWindow||Plain (unadorned) window||Click here|
In the JFC, the typical primary windows that users work with are based on the JFrame component. Unadorned windows that consist of a rectangular region without any title bar, close control, or other window controls are based on the JWindow component. Designers and developers typically use the JWindow component to create windows without title bars, such as splash screens.
For details on the use of windows, frames, panels, and panes, see Chapter 7.
You, the designer, have the first choice of a look and feel design. You can determine the look and feel you want users to receive on a specific platform, or you can choose a cross-platform look and feel.
Specify the Java look and feel, which is a cross-platform look and feel, explicitly. If you do not specify a look and feel or if an error occurs while specifying the name of a look and feel, the Java look and feel is used by default.
The following code can be used to specify the Java look and feel explicitly:
Because there is far more to the design of an application than the look and feel of components, it is unwise to give end users the ability to swap look and feel designs while working in your application. Switching look and feel designs in this way only swaps the look and feel designs of the components from one platform to another. The layout and vocabulary used are platform- specific and do not change. For instance, swapping look and feel designs does not change the titles of the menus.
Make it possible for your users to specify an auxiliary look and feel design, which provides alternative methods of information input and output for people with special needs.
In addition, you can download the Macintosh style look and feel (called "Mac OS" in the code) separately. The Macintosh style look and feel can be used only on Macintosh operating systems. It follows the specification for components under Mac OS 8.1. For details, see the Mac OS 8 Human Interface Guidelines.
|Java homepage :
||Previous | Next | Contents | Index | Search|
Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.