Table of Contents |
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. This 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 for information on playing sounds in applets.
- Getting configuration information
- Users can specify configuration information to the applet using command-line arguments (applications only) and parameters (applets only). For information about command-line arguments, see Application Command-Line Arguments. For information about parameters, see Defining and Using Applet Parameters.
- 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.
- 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 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.
Table of Contents |