+91-9990449935

 0120-4256464

Abstract Windowing Toolkit (AWT):

Abstract Windowing Toolkit (AWT) is used for GUI programming in java.

AWT Container Hierarchy:

hierarchy of awt

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.

Window:

The window is the container that have no borders and menubars. You must use frame, dialog or another window for creating a window.

Panel:

The Panel is the container that doesn't contain title bar and MenuBars. It can have other components like button, textfield etc.

Frame:

The Frame is the container that contain title bar and can have MenuBars. It can have other components like button, textfield etc.

Commonly used Methods of Component class:

1)public void add(Component c)
2)public void setSize(int width,int height)
3)public void setLayout(LayoutManager m)
4)public void setVisible(boolean)

Creating a Frame:

There are two ways to create a frame:
  • By extending Frame class (inheritance)
  • By creating the object of Frame class (association)

Simple example of AWT by inheritance:

public void setBounds(int xaxis, int yaxis, int width, int height); have been used in the above example that sets the position of the button.
awt example

Simple example of AWT by association:

Next TopicEvent Handling