Excersise:13 Create Login Form | Java | Tamizhan Goals

Login form

Excersise: 13

    Create a Login form.

Program


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/**/
public class user extends Applet 
{
Label l1,l2;
TextField t1,t2;
Button b1;
String str="",s="",s1="";
public void init()
{
l1=new Label("Enter the user name:");
t1=new TextField(15);
l2=new Label("Enter the password:");
t2=new TextField(15);
t2.setEchoChar('*');
b1=new Button("OK");
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
b1.addActionListener(new okbut());
}
class okbut implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
s=t1.getText();
s1=t2.getText();
if((s.equals("HAPPY"))&&(s1.equals("HAPPY")))
{
str="SUCCESSFULLY LOGIN";
repaint();
}
else
{
str="INVALID";
repaint();
}
}
}
public void paint(Graphics g)
{
g.setFont(new Font("Arial",Font.BOLD,20));
g.drawString(str,10,200);
}
}

Output

Post a Comment

Thanks for your comments. Please be visit and given positive review on our site.

Previous Post Next Post