Java AWT (Abstract Windowing Toolkit) is an API which contains large number of classes and methods used to create and manage windows GUI application.
AWT is the basic fundamentals upon which Swing have developed. It is used for GUI programming in Java. But now a days it is merely used because most GUI java programs are implemented using Swing because of its rich implementation of GUI controls and light-weighted nature.
Java AWT components are platform-dependent i.e. components are displayed according to the view of operating system. AWT is heavyweight i.e. its components uses the resources of system because they are being generated by underlying operating system (OS). For example if you are instantiating a text box in AWT that means you are actually asking OS to create a text box for you.
The Java AWT hierarchy classes are given below.
Component class is at the top of AWT hierarchy.
Component is an abstract class that encapsulates all attribute of visual component.
A component object is responsible for remembering the current foreground and background colours and the currently selected text font. All the elements like buttons, text fields, scrollbars etc are known as components.
The Container is a component in AWT that can contain another components like buttons, textfields, labels etc. Container is a subclass of component class.
The Panel is the container that doesn't contain title bar and menu bars. It can have other components like button, textfield etc.
Window class creates a top level window. Window does not have borders and menu bar.
The Frame is a sub class of Window .The Frame is the container that contain title bar and can have menu bars. It can have other components like button, textfield etc.
To develop a GUI, we need a frame. There are two ways to create a frame in AWT.
❮ Previous Next ❯