Abstract Window Toolkit release with java in 1995 by Sun Microsystems, provided a thin level of abstraction over the underlying native user interface. Main purpose of AWT is to support the Graphical user Interface( GUI) in programming.
It is the part of the Java Foundation Classes (JFC) the standard Application Programming Interface (API) for providing a graphical user interface (GUI) for a Java program. It's all the class must extend the AWT Packages, which are of two types
- java.awt package: Contains all of the classes for creating user interfaces and for painting graphics and images.
- java.awt.event package: Provides interfaces and classes for dealing with different types of events fired by AWT components.
- It is a robust event-handling model.
- Support the graphics and imaging tools, including shape, color, and font classes.
- Support the native user interface components in program
- The Swing classes are built on top of the AWT architecture.
- Also support to data transfer classes, in cut-and-paste form through the native platform/ clipboard.
- Define a layout managers, for flexible window layouts that do not depend on a particular window size or screen resolution ( i.e.totally independent from platform).
Since, AWT is the heavy weight component, but provide a general interface between Java and the native system, used for windowing,layout managers, and events.
First and important API is at the core of Java GUI programming and is also used by Swing and Java 2D. It contains:
- Several layout managers like FlowLayout, GridLayout, and BorderLayout.
- The interface between the native windowing system and the Java application.
- The interface to input devices such as mouse and keyboard by different ActionListen classes.
- A java.awt.datatransfer package for use Cut-and-paste, Drag and Drop from through the Native platform/ clipboard.
A basic set of GUI widgets such as buttons, text boxes, text Area, and menus. It also provides the AWT Native Interface in program, which enables rendering libraries compiled to native code to draw directly to an AWT Canvas object drawing surface. Neither Swing nor AWT are inherently thread safe because both strongly support native Interface.
Therefore, code that updates the GUI/ Processes events must be execute on the Event dispatching thread and if execute is failure , result in a deadlock or race condition, to solve such problem, use a Utility class called as SwingWorker which allow applications to perform time-consuming tasks following user-interaction events in the event dispatching thread.