The Abstract Windowing Toolkit (AWT) is the first set of nontrivial, publicly available, basic objects with which to build Java programs, with the focus on graphical user interfaces, or GUls. The AWT was built by Sun’s JavaSoft unit and is provided free for anyone to use for any reason whatsoever, in binary form. There is some controversy as to whether the AWT in its present condition will survive, but it does have three things going for it:
• It is the first Java toolkit available,
• It has gained rapid acceptance, and
• JavaSoft is committed to it.
The Java Foundation Class (JFC) provides two frameworks for building GUI-based Applications Abstract Window Toolkit (AWT) and swings.
The AWT package can be used by importing java.awt.* as follows:
import java.awt.*
The AWT has a set of Java classes that provide the standard set of user-interface elements (windows, menus, boxes, buttons, lists and so on). That is, AWT provides several facilities for drawing two-dimensional shapes, controlling colours and controlling fonts. Before using Java AWT classes, understanding the Java coordinate system is essential. By default, the top left comer of the component has coordinates (0,0). Here, the x-coordinate denotes the horizontal distance and the y-coordinate is the vertical distance from the upper left comer of the component, respectively. The applet’s width and height are 200 pixels each, in which the upper left comer is denoted by (0,0) and lower right comer is (200, 200).
Event Handlers An event is generated when an action occurs, such as a mouse click on a button or a carriage return (enter) in a text field. Events are handled by creating listener classes which implement listener interfaces. The standard listener interfaces are found in java.awt.event.
Layout Manager A layout manager is automatically associated with each container when it is created. Examples of this are BorderLayout and GridLayout.