Abstract Window Toolkit

From Wikipedia, the free encyclopedia

Windows form with some AWT examples
Windows form with some AWT examples

The Abstract Window Toolkit (AWT) is Java's original platform-independent windowing, graphics, and user-interface widget toolkit. The AWT is now part of the Java Foundation Classes (JFC) — the standard API for providing a graphical user interface (GUI) for a Java program.

The AWT provides, among other things:

When Sun Microsystems first released Java in 1995, AWT widgets provided a thin level of abstraction over the underlying native user interface. For example, creating an AWT check box would cause AWT directly to call the underlying native subroutine that created a check box. However, a check box on Microsoft Windows is not exactly the same as a check box on Mac OS or on the various types of UNIX. Some application developers prefer this model because it provides a high degree of fidelity to the underlying native windowing toolkit and seamless integration with native applications. In other words, a GUI program written using AWT looks like a native Microsoft Windows application when run on Windows, but the same program looks like a native Apple Macintosh application when run on a Mac, etc. However, some application developers dislike this model because they prefer their applications to look exactly the same on every platform.

In J2SE 1.2, the AWT's widgets were largely superseded by those of the Swing toolkit. In addition to providing a richer set of UI widgets, Swing draws its own widgets (by using Java 2D to call into low-level subroutines in the local graphics subsystem) instead of relying on the operating system's high-level user interface module. Swing provides the option of using either a System "look and feel" which uses the native platform's look and feel, or a cross-platform look and feel (the "Java Look and Feel") that looks the same on all platforms. Swing relies on AWT for its structural underpinnings and its interface to the native windowing system. However, it should be noted that neither AWT nor Swing are thread safe. Therefore, all code that updates the GUI or processes events should occur on the event dispatching thread. Failure to do so may result in a deadlock or race condition.

AWT is the GUI toolkit for a number of Mobile Java profiles. For example, Connected Device Configuration profiles require Java runtimes on mobile telephones to support AWT.

[edit] See also

[edit] External links

This article was originally based on material from the Free On-line Dictionary of Computing, which is licensed under the GFDL.