Introduction to AWT and Swing

AWT stands for Abstract Window Toolkit and is a platform-independent library that greatly simplifies the implementation of user interfaces. The AWT is a peer-based windowing library that contains platform-independent classes that directly associate with native objects on each operating system on which the code is executed.

Swing is a further implementation of AWT that adds a more comprehensive GUI system, but it is still based upon the AWT architecture. The main difference between Swing and AWT is that all the Swing components (except for top-level containers such as JFrame, JDialog, and JApplet) are lightweight components, whereas all of the AWT components are heavyweight.

We say, "except for JFrame, JDialog, and JApplet" because these are known as top-level containers. A top-level container is the root of a GUI containment hierarchy; hence, it is the starting point for adding all other containers and components.

As Swing components are completely lightweight, they make better use of resources. Also, the fact they are all written purely in Java and do not rely on the native objects ensures multiplatform consistency, and further, it also allows us to easily integrate look and feel, which we will look at later in this chapter.

In this book, we have chosen to use Swing components as opposed to AWT. However, in Chapter 9 we pay attention to more practical examples of using both AWT and Swing and note their differences.



Java 1.4 Game Programming
Java 1.4 Game Programming (Wordware Game and Graphics Library)
ISBN: 1556229631
EAN: 2147483647
Year: 2003
Pages: 237

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net