Java AWT Panels

AWT Window

A window is that one which can hold components; for example, frame is a window. In AWT, windows are of two types – Top-level and child.

1. Top-level Window (Frame and Applet)

A top-level window exists by itself, or to say, it has an independent existence. A top-level window comes with a border and title bar etc. as per the operating system's window decorations. The top-level window can be moved anywhere on the monitor and also can be resized. One Java application can have any number of windows (say, frames). One frame, being top-level, cannot be added to another frame. A frame can exist beside another; a frame cannot exist inside another frame (it is quiet contrary to child windows).

2. Child Window (Panel)

In Java, a child window does not have a border. Panel, being a child window, does not have a border. That is, you cannot see a panel. But still you can visualize the space taken by a panel by giving a background color to the panel. A child window cannot exist by itself. It comes into existence only when added to a top-level window. Any number of child windows can be added to a top-level window; that is, a frame can be added with a number of panels. A child window can be added to another. That is, panels can be nested for better layout arrangement and known as nested panels.

5 thoughts on “Java AWT Panels”

  1. Steven Troutman

    To get it to work in Netbeans
    39 public static void main(String args[])
    40 {
    41 PanelsDemo panelsDemo = new PanelsDemo();
    42 }

Leave a Comment

Your email address will not be published.