Java AWT Tutorials

adplus-dvertising
Abstract Window Toolkit( AWT)

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

  1. java.awt package: Contains all of the classes for creating user interfaces and for painting graphics and images.
  2. java.awt.event package: Provides interfaces and classes for dealing with different types of events fired by AWT components.
Awt Features
  1. It is a robust event-handling model.
  2. Support the graphics and imaging tools, including shape, color, and font classes.
  3. Support the native user interface components in program
  4. The Swing classes are built on top of the AWT architecture.
  5. Also support to data transfer classes, in cut-and-paste form through the native platform/ clipboard.
  6. 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).
Architecture of AWT

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.

The AWT provides two levels of APIs

First and important API is at the core of Java GUI programming and is also used by Swing and Java 2D. It contains:

  1. Several layout managers like FlowLayout, GridLayout, and BorderLayout.
  2. The interface between the native windowing system and the Java application.
  3. The interface to input devices such as mouse and keyboard by different ActionListen classes.
  4. 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.

adplus-dvertising