User Registration and Login using Java AWT with Panel without Data base

User Registration and Login using Java AWT with Panel

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Testing extends Frame implements ActionListener
{
    Button b1,b2,b3;
    TextField t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12;
    Label l1,l2,l3,l4;
    String name,email,ph,password,add,email1,password1;
    Panel p1,p2,p3;
    Testing()
    {
       
       
       
        p1=new Panel();
        add(p1);
        p1.setBounds(10,20,200,350);
        p1.setBackground(Color.red);
        p1.setLayout(null);
       
          p2=new Panel();
        add(p2);
        p2.setBounds(220,120,200,350);
        p2.setBackground(Color.yellow);
         p2.setLayout(null);
       
          p3=new Panel();
        add(p3);
        p3.setBounds(430,20,200,350);
        p3.setBackground(Color.ORANGE);
         p3.setLayout(null);
       
          l1=new Label("Enter Details");
        p1.add(l1);
        l1.setBounds(90,60,130,35);
       
              t1=new TextField();
        p1.add(t1); 
        t1.setBounds(60,100,130,35);
           
           
            t2=new TextField();
        p1.add(t2);
        t2.setBounds(60,140,130,35);
           
             t3=new TextField();
            p1.add(t3);
            t3.setBounds(60,180,130,35);
       
           
           
            t4=new TextField();
            p1.add(t4);
            t4.setBounds(60,215,130,35);
            t4.setEchoChar('*');
           
             t5=new TextField();
            p1.add(t5);
            t5.setBounds(60,250,130,35);
           
     
           
           
             l2=new Label("Information");
            p2.add(l2);
            l2.setBounds(10,60,130,35);
           
              t6=new TextField();
            p2.add(t6);
            t6.setBounds(10,100,130,35);
            t6.setEditable(false);
           
            t7=new TextField();
            p2.add(t7);
            t7.setBounds(10,140,130,35);
            t7.setEditable(false);
             t8=new TextField();
            p2.add(t8);
            t8.setBounds(10,180,130,35);
         t8.setEditable(false);
           
           
            t9=new TextField();
            p2.add(t9);
            t9.setBounds(10,215,130,35);
            t9.setEditable(false);
           
            t10=new TextField();
            p2.add(t10);
            t10.setBounds(10,250,130,35);
            t10.setEditable(false);
           
           
            b1=new Button("Register");
            p1.add(b1);
            b1.setBounds(70,290,110,35);
            b1.addActionListener(this);
         
            b2=new Button("Clear");
            p2.add(b2);
            b2.setBounds(30,290,110,35);
            b2.addActionListener(this);
         
             
               l2=new Label("Login");
            p3.add(l2);
            l2.setBounds(30,60,130,35);
             
                t11=new TextField();
            p3.add(t11);
            t11.setBounds(10,100,130,35);
         
           
             t12=new TextField();
            p3.add(t12);
            t12.setBounds(10,145,130,35);
              t12.setEchoChar('*');
             
              b3=new Button("Login");
            p3.add(b3);
            b3.setBounds(30,185,100,35);
            b3.addActionListener(this);
           
             
               l4=new Label();
            p3.add(l4);
            l4.setBounds(30,255,100,35);
            l4.setForeground(Color.red);
           
              setLayout(null);
           
    }
   
    public void actionPerformed(ActionEvent e)
    {
        if(e.getSource()==b1)
        {
            name=t1.getText();
            email=t2.getText();
            ph=t3.getText();
            password=t4.getText();
            add=t5.getText();
           
       
        }
        else if(e.getSource()==b3)
        {
            email1=t11.getText();
            password1=t12.getText();
           
            if(email.compareTo(email1)==0&&password.compareTo(password1)==0)
            {
                  t6.setText(name);
                  t7.setText( email);
                  t8.setText(ph);
                  t9.setText( password);
                  t10.setText( add);
            }
            else
            {
                l4.setText("Invalid Details");
            }
         
        }
        else
        {
             t1.setText("");
          t2.setText( "");
          t3.setText("");
          t4.setText( "");
          t5.setText( "");
         
           t6.setText("");
          t7.setText( "");
          t8.setText("");
          t9.setText( "");
          t10.setText( "");
        }
    }
   
    public static void main(String[] args)
    {
            Testing obj=new Testing();
            obj.setSize(900,800);
            obj.setVisible(true); 
         
    }
}

0 Comments