Friday 13 March 2015

Simple Login in Applet

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

/*
<applet code="LoginForm" height=800 width=500>
</applet>
*/

public class LoginForm extends Applet implements ActionListener
{
    Label l1,l2,l3;
    TextField t1,t2;
    Button b1;

    public void init()
    {
        l1=new Label("User Name :");
        add(l1);
       
        l2=new Label("Password  :");
        add(l2);
       
        l3=new Label();
        add(l3);
       
        t1=new TextField(20);
        add(t1);
       
        t2=new TextField(20);
        t2.setEchoChar('*');
        add(t2);
       
        b1=new Button("LogIn");
        add(b1);

        b1.addActionListener(this);
       
    }
   
    public void actionPerformed(ActionEvent e)
    {
        if(e.getSourse()==b1)
        {
            l3.setText("Welcome "+t1.getText());
        }
    }
}

No comments: