import java.awt.*;
import java.applet.Applet;
import java.awt.image.*;

public class pass extends java.applet.Applet

{
 Image bild;

 public void init()
 {
 setLayout(new GridLayout(4,2));
 Panel p = new Panel();
 p.add(new Label("Username: "));
 add("North", p);

 mname = new TextField();
 mname.setEditable(true);
 add("North", mname);


 Panel p2 = new Panel();
 p2.add(new Label("Password: "));
 add("North", p2);

 passw = new TextField();
 passw.setEditable(true);
 add("North", passw);


 Panel p3 = new Panel();
 p3.add(new Label("Status: "));
 add("North", p3);

 access = new TextField();
 access.setEditable(false);
 add("North", access);

 Panel p1 = new Panel();
 p1.add(new Button("OK"));
 add("East", p1);

 String s;
 bild = getImage(getDocumentBase(), getpic());

 }

   public boolean handleEvent(Event evt)
   {
    if (evt.id == Event.WINDOW_DESTROY) System.exit(0);
    return super.handleEvent(evt);
   }
   
   public String getpic()
   {
    s = getParameter("bild");
    return s;
   }

   public void paint(Graphics g)
   {
    g.drawImage(bild, 0, 0, this);
    g.drawImage(bild, 78, 0, this);
    g.drawImage(bild, 156, 0, this);
    g.drawImage(bild, 234, 0, this);
   }



   public boolean action(Event evt, Object arg)
   {

    user user1[] = new user[2];
    user1[0]=new user("User1", "God");
    user1[1]=new user("User2", "secret");


    if (arg.equals("OK"))
     { 
       if (mname.getText().equals(user1[0].getname()))
       {
        if (passw.getText().equals(user1[0].getword()))
        {
         access.setText("You have access!");
        }
        else access.setText("Invalid Password");
       }

       else if (mname.getText().equals(user1[1].getname()))
       {
        if (passw.getText().equals(user1[1].getword()))
         {
          access.setText("You have access!");
         }
         else access.setText("Invalid Password");
       }

       else access.setText("Invalid Username");
     }
    
    else return super.action(evt, arg);
    return true;
   }

  private String word;
  private TextField mname;
  private TextField passw;
  private TextField access;

}

class user
{
 public user(String name, String word)
 {
  member = name;
  password = word;
 }

 public String getname()
 {
  return member;
 }

 public String getword()
 {
  return password;
 }

 public String member;
 public String password;
}

