Previous | Next | Trail Map | Creating a User Interface (AWT Only) | Contents

Overview of the Java UI

This lesson gives an overview of what the Java environment provides to help you create a user interface (UI). UI is a broad term that refers to all sorts of communication between a program and its users. UI is not only what the user sees, but what the user hears and feels. Even the speed with which a program interacts with the user is an important part of the program's UI.

The Java environment provides classes for the following UI functionality:

Presenting a graphical UI (GUI)
This is the preferred UI for most Java programs. The rest of this trail concentrates on this topic.

Playing sounds
Right now, applets can play sounds but applications can't (at least not in a portable way). See Playing Sounds(in the Writing Applets trail) for information on playing sounds in applets.

Getting configuration information
Users can specify configuration information to a program using command-line arguments (applications only) and parameters (applets only). For information about command-line arguments, see Application Command-Line Arguments(in the Learning the Java Language trail). For information about parameters, see Defining and Using Applet Parameters(in the Writing Applets trail).

Saving user preferences using properties
For information that applications need to save even when they're not running, you can use properties. Applets usually can't write properties to the local file system, due to security restrictions. For information on using properties, see Properties(in the Learning the Java Language trail).

Getting and displaying text using the standard input, output, and error streams
Standard input, output, and error are the old-fashioned way of presenting a user interface. They're still useful for testing and debugging programs, as well as for functionality that's not aimed at the typical end user. See The Standard I/O Streams(in the Learning the Java Language trail) for information on using standard input, output, and error.

Applets and applications commonly present information to the user and invite the user's interaction using a GUI. The part of the Java environment called the Abstract Window Toolkit (AWT) contains a complete set of classes for writing GUI programs.

AWT Components

The AWT provides many standard GUI components such as buttons, lists, menus, and text areas. It also includes containers (such as windows and menu bars) and higher-level components (such as a dialog for opening or saving files).

Other AWT Classes

Other classes in the AWT include those for working with graphics contexts (including basic drawing operations), images, events, fonts, and colors. Another important group of AWT classes are the layout managers, which manage the size and position of components.

The Anatomy of a GUI-Based Program

The AWT provides a framework for drawing and event handling. Using a program-specific hierarchy of containers and components, the AWT forwards events (such as mouse clicks) to the appropriate object. The same hierarchy determines the order in which containers and components draw themselves.


Previous | Next | Trail Map | Creating a User Interface (AWT Only) | Contents