AWT-(Abstract Window Toolkit)

Three categories of AWT controls are :
1.    Non-Menu Components
2.    Container Components
3.    Menu Components
Two categories of Container Components are :
1.    Panel and Applet
2.    Window and Frame
Two reasons for the bifurcation :
1.    Based on the type of Application
2.    Based on the type of Layout Manager

Panel and Applet has Flow Layout as its default Layout Manager and Frame and Window has Border as its Layout Manager














In a Border Layout one control in one position in a frame at a time.

1)    Application and Applet









1) Application
import java.awt.*;
class Login
{
    Frame f;
    Label l1, l2;
    TextField tf1, tf2;
    Button b1;
    Login()
    {
        f=new Frame("Login");
        l1=new Label("Login");
        l2=new Label("Password");
        tf1=new TextField(10);
        tf2=new TextField(10);
        b1=new Button("OK");

        //Change in Layout Manager if necessary
        f.setLayout(new FlowLayout());

        f.add(l1);
        f.add(tf1);
        f.add(l2);
        f.add(tf2);
        f.add(b1);

        f.setSize(100,400);
        f.setVisible(true);
    }
    public static void main(String args[])
{
        Login x = new Login();
    }
}

1) Applet
import java.awt.*;
import java.applet.*;
public class LoginApplet extends Applet
{
    Frame f;
    Label l1, l2;
    TextField tf1, tf2;
    Button b1;

    public void init()
    {
        f=new Frame("Login");
        l1=new Label("Login");
        l2=new Label("Password");
        tf1=new TextField(10);
        tf2=new TextField(10);
        b1=new Button("OK");

        add(l1);
        add(tf1);
        add(l2);
        add(tf2);
        add(b1);

    }
}

Click new -> File -> html    and save this file as CodeDocTextApplet.html

<BODY>

<APPLET code= LoginApplet.class HEIGHT=200 WIDTH=400 >

</APPLET>

</BODY>