JaiswalTraining

Get the online training



Corejava Servlet Jsp  Php  Hibernate  Ajax Web Service   Ejb2.1 Ejb3.0 Struts Struts2  JPA Spring Ibatis   JSF    JSF2.0  CoreJavaDesignPattern    Jquery  Flex J2EE-Design-Patterns  Jboss7  Maven  Contact Me                                                                                                                                                                        
            IGNOU SMU PTU Project                                           Training                                                                                                                              
              

Contact Us  0091- 9210721663         jaiswaltraining@gmail.com




Corejava
Servlet
Jsp
Php
Hibernate
Ajax
Web Service
Ejb2.1
Ejb3.0
Struts  
Struts2
JPA
Spring
Ibatis
JSF
JSF2.0
CoreJavaDesignPattern
Jquery
Flex
J2EE-Design-Patterns
Jboss7
Maven








Introduction to AWT

  • “Abstract windows toolkit (AWT)” is a portable GUI Library in java.
  • It is a java package for developing GUI Applications.
  • Different set of GUI components are encapsulated in rich set of AWT classes
  • It is the connection between the application and platform specific GUI
AWT library

Java AWT provides multi platform windowing library
It is a standard part of Java environment.
It provides all the basic functionality that is used for developing GUI application.
It has classes which encapsulates different useful GUI components.

This is imported using java.awt.* package
The AWT library Contains different objects that are arranged in hierarchy.
The Objects include
Containers and
Components like labels, text fields, buttons etc.
The hierarchy is represented based on the inheritance of objects across different classes.


AWT Hierarchy



AWT Classes

AWT provides different classes that provide the look and feel state for the interfaces.

Some of the classes are

  1. Graphics
  2. Color
  3. Menu
  4. Font etc…

Awt Frame Example

Frame creation in two ways
  1. Extending Frame class
  2. Creating object of Frame class

  1. Creating a frame in awt by extending the Frame class


01 import java.awt.Frame;
02 
03 
04 public class frame1  extends Frame
05  {
06   public frame1() {
07   
08   setVisible(true);
09   setSize(200,200);
10     setTitle("my first frame");
11   }
12   
13   public static void main(String[] args) {
14     
15     new frame1();
16   }
17 }

Output

Download the code

  1. Creating a frame in awt by creating object of the Frame class


01 import java.awt.Color;
02 import java.awt.Frame;
03 
04 public class frame2 
05  {  
06   public static void main(String[] args) {
07   Frame fr=new Frame();  
08   fr.setVisible(true);
09   fr.setSize(200,200);
10   fr.setTitle("my first frame");
11   fr.setBackground(Color.red);
12   }
13 }

Output



Download the code


Frame with label and text field

01 import java.awt.Frame;
02 import java.awt.Label;
03 import java.awt.TextField;
04 
05 public class frame3 extends Frame
06  {
07   public frame3() {
08   setVisible(true);
09   setSize(200,200);
10   Label l1=new Label("name");
11   TextField t1=new TextField(12);
12   add(t1,"East");
13   add(l1,"West");
14     setTitle("my first frame");
15     pack();
16   }
17   
18   public static void main(String[] args) {
19     new frame3();
20   }
21 }

Output



Download the code