AWT Container Classes

Posted By on November 7, 2014

Download PDF
Containers and Components
AWT Component Classes
Top-Level Containers: Frame, Dialog and Applet

Each GUI program has a top-level container. The commonly-used top-level containers in AWT are Frame, Dialog and Applet:

  • AWT_Frame.png A Frame provides the “main window” for the GUI application, which has a title bar (containing an icon, a title, the minimize, maximize/restore-down and close buttons), an optional menu bar, and the content display area. To write a GUI program, we typically start with a subclass extending from java.awt.Frame to inherit the main window as follows:
    import java.awt.Frame;  // Using Frame class in package java.awt
    // A GUI program is written as a subclass of Frame - the top-level container
    // This subclass inherits all properties from Frame, e.g., title, icon, buttons, content-pane
    public class MyGUIProgram extends Frame {
       // Constructor to setup the GUI components
       public MyGUIProgram() { ...... }
       // Other methods
       // The entry main() method
       public static void main(String[] args) {
          // Invoke the constructor (to setup the GUI) by allocating an instance
          new MyGUIProgram();
  • AWT_Dialog.gif An AWT Dialog is a “pop-up window” used for interacting with the users. A Dialog has a title-bar (containing an icon, a title and a close button) and a content display area, as illustrated.
  • An AWT Applet (in package java.applet) is the top-level container for an applet, which is a Java program running inside a browser. Applet will be discussed in the later chapter.
Secondary Containers: Panel and ScrollPane

Secondary containers are placed inside a top-level container or another secondary container. AWT also provide these secondary containers:

  • Panel: a rectangular box under a higher-level container, used to layout a set of related GUI components in pattern such as grid or flow.
  • ScrollPane: provides automatic horizontal and/or vertical scrolling for a single child component.
  • others.
Hierarchy of the AWT Container Classes

The hierarchy of the AWT Container classes is as follows:


As illustrated, each Container has a layout.

Containers and Components
AWT Component Classes

Download PDF

Posted by Akash Kurup

Founder and C.E.O, World4Engineers Educationist and Entrepreneur by passion. Orator and blogger by hobby