The classes of the package can be rougly divided into: related methods of the Component class, which is the root in the hierarchy of GUI components. In AWT we have classes for each component as shown in the above diagram. hierarchy diagram above, Frame and Dialog are subclasses of Window class. AWT Hierarchy. The Java AWT (Abstract Windowing Toolkit) contains the fundamental classes used for constructing GUIs. The abstract Component class is the base class for the AWT. Many AWT classes are derived from it.


Author: Paxton Kohler V
Country: Nepal
Language: English
Genre: Education
Published: 27 March 2016
Pages: 559
PDF File Size: 49.42 Mb
ePub File Size: 49.33 Mb
ISBN: 136-5-20829-826-5
Downloads: 24088
Price: Free
Uploader: Paxton Kohler V


In the above figure, the top-level Frame contains two Awt class hierarchy. There are five components: In a GUI program, a component must be kept in a container.


You need to identify a container to hold the components. Every container has a method called add Component c.

A container say c can invoke c. A Frame provides the "main window" for your GUI application. To write a GUI program, we typically start with a subclass extending from java. Frame to inherit the main window as follows: 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. Panel and ScrollPane Secondary containers are placed inside a top-level container or another secondary container. AWT provides these secondary containers: As illustrated, a Container has a LayoutManager awt class hierarchy layout awt class hierarchy components in a certain pattern.

Label provides a descriptive text string.

GUI Programming - Java Programming Tutorial

Take note that System. You could use a Label to label another component such as text field to provide a text description.

Awt class hierarchy first constructor constructs a Label object with the given text string in awt class hierarchy given alignment. Note that three static constants Label. CENTER are defined in the class for you to specify the alignment rather than asking you to memorize arbitrary integer values.

The second constructor constructs a Label object with the given text string in default of left-aligned.


The third constructor constructs a Label object with an initially empty string. You could set the label text via the setText method later.

AWT in Java GUI | Core Java Tutorial | Studytonight

Similarly, the getAlignment and setAlignment methods can be used to retrieve and modify the alignment of the text. Declare the component with an identifier name ; Awt class hierarchy the component by invoking an appropriate constructor via the new operator; Identify the container such as Frame or Panel designed to hold this awt class hierarchy.

The container can then add this component onto itself via aContainer. Every container has a add Component method. Take note that it is the container that actively and explicitly adds a component onto itself, NOT the other way.

5.1 Overview of the AWT

In the case, the Java compiler will assign an anonymous identifier for the allocated object. You will not be able to reference an anonymous instance in your program after it is created. This awt class hierarchy usually alright for a Label instance as there is often no need to reference a Label after it is constructed.

Button awt class hierarchy a GUI component that triggers a certain programmed action upon clicking. The first constructor creates a Button object with the given label painted over the button.