The JavaTM Tutorial

| Start of Tutorial > Start of Trail > Start of Lesson | Search

Trail: Overview

## Advanced GUI Building

> The Java 2D API, JavaBeans, and the Sound engine provide advanced functionality for building interesting, modular, and more usable user interfaces.

### 2D Graphics

> The Java 2D API, introduced in JDK 1.2, gives you everything you need to enhance the appearance of your GUI with shapes, color, stylized text, foreign-language text, and image processing. The Java 2D API also introduces a printing model that gives you more control, power, and flexibility in application-level printing.

> The `java.awt` and the `java.awt.image` packages are enhanced. New packages are `java.awt.color`, `java.awt.font`, `java.awt.geom`, and `java.awt.print`.

> - The `java.awt` package includes the new `Graphics2D` class for better geometry, transformation, color, and text rendering, and has enhanced color and font capabilities. The `Color` class supports a full range of color spaces, and the `Font` class supports any font on the system. You also get more texture map and fill pattern options; image compositing and transparency capabilities; more line widths, end caps, line styles, and dash patterns; and a flexible device model.
> - The `java.awt.color` package supports high-quality color output, using profiles and a full array of color spaces for defining device-dependent and device-independent color attributes.
> - The `java.awt.font` package supports glyphs and text with multiple fonts that can be transformed and drawn into a graphics context.
> - The `java.awt.geom` package lets you create a wide range of shapes, including arbitrary and point-by-point paths; perform affine transformations (transformations that maintain parallel lines); and use float and/or double precision in most cases.
> - The `java.awt.image` package supports a full range of image-processing capabilities, including affine transformation, amplitude scaling, lookup-table modification, color conversions, and convolutions. The `BufferedImage` class describes an image with an accessible buffer of image data consisting of color model and data layout information.
> - The `java.awt.print` package introduces for the Win32 and Solaris platforms a printing model whereby the printing system drives the printing process to give you more control, power, and flexibility in application-level printing. The Java 2D printing system can print all Java 2D regular and composite graphics, and supports soft collating, reverse-order printing, and booklet printing.

### Sound

> Before JDK 1.2, only applets could play sound and only one sound format was supported. JDK 1.2 adds an `Applet` class method, `newAudioClip`, that enables all kinds of programs to load and play sounds. The Sound engine in JDK 1.2 adds support for several sound formats, including AIFF, WAV, MIDI, and RMF.

### JavaBeans

> Introduced in JDK 1.1, JavaBeans let you build reusable and interchangeable software components that can be visually constructed and manipulated in builder tools. JavaBeans can be simple, such as pushbuttons or dialog boxes, or more complex, such as spreadsheets and calendars. Individual JavaBeans vary in functionality, but most have the following features in common:
> - Introspection, which allows a builder tool to analyze how a Bean works.
> - Customization, which allows a user to alter the appearance and the behavior of a Bean.
> - Events, which allow Beans to fire events and to inform builder tools about events.
> - Properties, which allow Beans to be manipulated programmatically and to support customization.
> - Persistence, which allows customized Beans in an application builder to have their states saved and restored. Typically persistence is used with an application builder's Save and Load menu commands to restore any work that has gone into constructing an application.
> In JDK 1.2 JavaBeans includes an extensible and standard runtime containment and services protocol, as well as drag-and-drop support. When a Bean is introduced to its environment, it knows it is running inside the Java Virtual Machine (JVM) and has access to the core Java API. The protocol provides a standard way to nest Beans within other Beans and to have the nested Bean be able to access additional runtime services from its environment. Also, the environment or containing Bean can extend its capabilities directly to the nested Bean.

> Drag-and-drop support means that Java and non-Java applications can readily share data. JavaBeans Drag and Drop works with the JFC accessibility API and can be extended to support diverse input devices.

| Start of Tutorial > Start of Trail > Start of Lesson | Search