The Abstract Window Toolkit vs. Swing
The Java Development Kit contains two sets of widget- and
utility classes for creating simple graphical user-interfaces:
the Abstract Window Toolkit or AWT, and the
Java Foundation Classes or JFC, or popularly called Swing.
Small applications with user-interfaces are often
called Applets.
Main features of the AWT are:
- It offers widgets and features that are available (and functionally
but not visually identical) on all computing platforms.
- It uses the computing platform's window system for some of its
operations.
- It contains some "native" code and is thus not 100% portable.
A tutorial on writing AWT applets can be found at:
http://java.sun.com/docs/books/tutorial/applet/index.html".
Main features of Swing are:
- It offers a Pluggable Look & Feel.
User-Interfaces can have the same look and feel on all computing platforms.
There is at least a choice between the "Java" and the "Windows" look and feel.
- It does not use the computing platform's window system for most
operations. (Opening a new top-level window is an exception.)
- It is implemented using 100% "pure" Java. There is no native code in Swing.
- Many Swing components are not thread safe.
All operations on Swing components should be performed in the
event handling thread!
A tutorial on writing Swing applets can be found at:
http://java.sun.com/docs/books/tutorial/uiswing/index.html.
AWT and Swing have some common properties:
- They offer an event model
that is closely tied to the object-oriented
and layered model for user-interfaces.
- They offer classes for communicating with a Web-browser and with remote
machines over Internet, for loading and manipulating images, and for loading
and playing sound.
- They conform to the JavaBeans
standard for reusable components.
Combining AWT and Swing in a single application or applet often leads to
problems because AWT uses heavyweight components and Swing
uses lightweight components.
AWT places components on top of an application's main window through the
window system. Swing draws components on top of the application's main
window by itself. When both techniques are mixed, the window system's
components, created by AWT, are always shown on top.