As a part of the learn Java series, let’s look at the concept of AWT in this particular article. We have as of now seen lot of other concepts related to Java. Java training Pune can provide you with insights related to this topic. Please take the help of a best Java institute in Pune.
AWT is also known as Abstract Window ToolKit. It is a portable GUI library amongst Solaris and Windows 95/NT and Mac System 7.X(soon) for solitary applications as well as applets. Since it can be utilized as a part of applets it can be utilized on IRIX, SunOS, HP/UX, Linux which Netscape 2.0 backs.
It is a Java package and can be utilized as a part of any Java program by importing in java.awt.* via means of the import keyword. The documentation for the package is accessible on the Java homepage. The package will be secured quickly as this document is not viewed as cutting edge material since it doesn’t talk about Peers, ImageConsumers/Producers, Toolkits and other advanced AWT kind. It is prescribe you take a gander at the source code to perceive how the AWT truly functions.
AWT contains expansive number of classes and methods that permits you to create and oversee windows GUI application. AWT is the establishment whereupon Swing is made. It is utilized for GUI programming as a part of Java. Yet, now a days it is only utilized on the grounds that most GUI Java programs are actualized utilizing Swing in view of its rich implementation of GUI controls and light-weighted nature.
Structure of the AWT:
The structure of the AWT is somewhat straightforward: Components are added to and afterward laid out by layoutmanagers in Containers. We have an assortment of event handling, menu, fonts, graphic classes notwithstanding those two, however they’ll be just quickly talked about here.
Nothing keeps us from utilizing threads, audio, I/O, networking classes close by the AWT. The AWT without anyone else’s input is rather bare and empty. Envision a text editor that couldn’t spare! As a side note, the AWT can be utilized as a part of a stand-alone Java application or in an applet that is embedded inside a HTML document.
Now, lets take a look at the AWT hierarchy and its components
Component class is at the highest point of AWT hierarchy structure. Component happens to be a dynamic class which encapsulates all attributes of visual segment. A component object is in charge of recalling the present foreground and background colors and the as of now chosen text font.
Container is a component in AWT that contains another sub components as in button, text field, tables and so on. A container happens to be a subclass of component class. Container class monitors components that are added to another component.
The panel class happens to be a concrete sub class of container. Panel does not consist of a title bar, menu bar or a border.
A Window class helps to create a top level window. Window does not have borders and a menu bar in it.
A frame is a sub class of Window and consisting of resizing canvas. It happens to be a container that consists of a few distinct components like button, title bar, textfield, label and so forth. In Java, a large portion of the AWT applications are created utilizing Frame window. Frame class has two unique constructors namely,
Frame() throws HeadlessException
Frame(String title) throws HeadlessException
Creation of a Frame:
A frame can be created in two ways. They are as follows:
By instantiating Frame class.
By extending Frame class.
This would help you in understanding the concept of AWT. Best Java courses in Pune, can also teach you this and other concepts.
You may also like this: