Java AWT (Abstract Window Toolkit) is an API to develop Graphical User Interface (GUI) or windows-based applications in Java.
Java AWT components are platform-dependent i.e. components are displayed according to the view of operating system. AWT is heavy weight i.e. its components are using the resources of underlying operating system (OS).
The java.awt package provides classes for AWT API such as TextField, Label, TextArea, RadioButton, CheckBox, Choice, List etc
2. Abstract Window Tool Kit
• Java AWT is an API that contains large number of classes and methods
to create and manage graphical user interface ( GUI ) applications.
• The AWT was designed to provide a common set of tools for GUI
design that could work on a variety of platforms.
• AWT was Java’s first GUI Framework.
• AWT is the foundation upon which Swing is made i.e Swing is a
improved GUI API that extends the AWT.
Simmi S,Dept of CS
3. AWT
• Java AWT components are platform-dependent i.e. components are
displayed according to the view of operating system.
• AWT is heavy weight i.e. its components are using the resources of
underlying operating system (OS)
• Java AWT components are platform-dependent i.e. components are
displayed according to the view of operating system.
• The java.awt package provides classes for AWT API such as TextField,
Label, TextArea, RadioButton, CheckBox, Choice, List etc.
Simmi S,Dept of CS
5. Components
• All the elements like the button, text fields, scroll bars, etc. are called
components.
• In Java AWT, there are classes for each component as shown in above
diagram.
• In order to place every component in a particular position on a
screen, we need to add them to a container.
Simmi S,Dept of CS
6. Container
• The Container is a component in AWT that can contain another
components like buttons, textfields, labels etc.
• The classes that extends Container class are known as container such
as Frame, Dialog and Panel.
• It is basically a screen where the components are placed at their
specific locations.
• Thus it contains and controls the layout of components.
•
Simmi S,Dept of CS
7. Types of containers:
There are four types of containers in Java AWT:
• Window
• Panel
• Frame
• Dialog
Simmi S,Dept of CS
8. Types of containers:
• Window
• The window is the container that have no borders and menu bars.
You must use frame, dialog or another window for creating a window.
We need to create an instance of Window class to create this
container
• Panel
• The Panel is the container that doesn't contain title bar, border or
menu bar. It is generic container for holding the components. It can
have other components like button, text field etc. An instance of
Panel class creates a container, in which we can add components.
Simmi S,Dept of CS
9. Types of containers:
• Frame
• The Frame is the container that contain title bar and border and can
have menu bars.
• It can have other components like button, text field, scrollbar etc.
• Frame is most widely used container while developing an AWT
application.
• Frame is a subclass of Window and have resizing canvas.
Simmi S,Dept of CS
10. Types of containers:
• The Dialog control
• The Dialog control represents a top level window with a border and a
title used to take some form of input from the user.
• It inherits the Window class.
• Unlike Frame, it doesn't have maximize and minimize buttons.
• Frame and Dialog both inherits Window class.
• Frame has maximize and minimize buttons but Dialog doesn't have.
Simmi S,Dept of CS
11. Creating a Frame
There are two ways to create a Frame. They are,
• By Instantiating Frame class
• By extending Frame class
Simmi S,Dept of CS
12. Points to Remember:
• While creating a frame (either by instantiating or extending Frame
class), Following two attributes are must for visibility of the frame:
• setSize(int width, int height);
• setVisible(true);
• When you create other components like Buttons, TextFields, etc. Then
you need to add it to the frame by using the method -
add(Component's Object);
• You can add the following method also for resizing the frame -
setResizable(true);
Simmi S,Dept of CS