JaVa
   

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 tutorial, we have chosen to use Swing components as opposed to AWT. However, in we pay attention to more practical examples of using both AWT and Swing and note their differences.

JaVa
   
Comments