Java Frame to build a Student Registration Form

Share it Please

/* student registration form using  frame  and  interface 
  actionlistener , itemlistener*/ 

import java.awt.*;
import java.awt.event.*;

class studentform extends Frame implements ActionListener,ItemListener
{
 
 Panel p,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,a;
 Label l,l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16,l17,l18,a1,a2;
 TextField tf1,tf2,tf3,tf5,tf6,tf7,tf8,tf9,tf10,tf11,tf12,tf13,tf14,tf15,tf16,tf17,tf18;
 Checkbox c1,c2,c3,c4,male,female,BE,ME,BCA,MCA;
 CheckboxGroup cbg,cbg1;
 List lst;
 Choice ch1,ch2,ch3;
 TextArea ta,ta1;
 Button b1,b2,b3;
 Font f1;
 String st1,st2,st3,st4,st5,st6,st7,st8,st9,sd1,sd2,sd3,sc1,sc2,sc3,sc4,sb,sb1,sl;

 studentform()
 {
  setTitle("Student Registration Form..");
  setSize(500,500);
  setVisible(true);
 
  GridLayout gr=new GridLayout(19,1);
  setLayout(gr);
 
  f1=new Font("courier New",Font.BOLD,25);
 
  p=new Panel();
  l=new Label("Student Registration Form");
  p.setFont(f1);
  p.add(l);
  add(p);
 
  p1=new Panel();
  l1=new Label("First name    ");
  tf1=new TextField(10);
  p1.setLayout(new FlowLayout(FlowLayout.LEFT));
 
  p1.add(l1);
  p1.add(tf1);
  add(p1);
 
  p2=new Panel();
  l2=new Label("Middle name");
  tf2=new TextField(10);
  p2.setLayout(new FlowLayout(FlowLayout.LEFT));
  p2.add(l2);
  p2.add(tf2);
  add(p2);
 
  p3=new Panel();
  l3=new Label("Last name    ");
  tf3=new TextField(10);
  p3.setLayout(new FlowLayout(FlowLayout.LEFT));
  p3.add(l3);
  p3.add(tf3);
  add(p3);
 
  p4=new Panel();
  l4=new Label("Date of Birth");
  ch1=new Choice();
  ch2=new Choice();
  ch3=new Choice();
 
  ch1.add("Day");
  ch1.add("1");
  ch1.add("2");
  ch1.add("3");
  ch1.add("4");
  ch1.add("5");
  ch1.add("6");
  ch1.add("7");
  ch1.add("8");
  ch1.add("9");
  ch1.add("10");
  ch1.add("11");
  ch1.add("12");
  ch1.add("13");
  ch1.add("14");
  ch1.add("15");
  ch1.add("16");
  ch1.add("17");
  ch1.add("18");
  ch1.add("19");
  ch1.add("20");
  ch1.add("21");
  ch1.add("22");
  ch1.add("23");
  ch1.add("24");
  ch1.add("25");
  ch1.add("26");
  ch1.add("27");
  ch1.add("28");
  ch1.add("29");
  ch1.add("30");
  ch1.add("31");
 
  ch2.add("Month");
  ch2.add("1");
  ch2.add("2");
  ch2.add("3");
  ch2.add("4");
  ch2.add("5");
  ch2.add("6");
  ch2.add("7");
  ch2.add("8");
  ch2.add("9");
  ch2.add("10");
  ch2.add("11");
  ch2.add("12");
 
  ch3.add("Year");
  ch3.add("1990");
  ch3.add("1991");
  ch3.add("1992");
  ch3.add("1993");
  ch3.add("1994");
  ch3.add("1995");
  ch3.add("1996");
  ch3.add("1997");
  ch3.add("1998");
  ch3.add("1999");
  ch3.add("2000");
  ch3.add("2001");
  p4.setLayout(new FlowLayout(FlowLayout.LEFT));
  p4.add(l4);
  p4.add(ch1);
  p4.add(ch2);
  p4.add(ch3);
   add(p4);
 
  p5=new Panel();
  l5=new Label("Email Id       ");
  tf5=new TextField(10);
  p5.setLayout(new FlowLayout(FlowLayout.LEFT));
  p5.add(l5);
  p5.add(tf5);
  add(p5);
 
  p6=new Panel();
  l6=new Label("Mobile no     ");
  tf6=new TextField(10);
  p6.setLayout(new FlowLayout(FlowLayout.LEFT));
  p6.add(l6);
  p6.add(tf6);
  add(p6);
 
  p7=new Panel();
  cbg=new CheckboxGroup();
  male=new Checkbox("Male",cbg,true);
  female=new Checkbox("Feale",cbg,false);
  p7.setLayout(new FlowLayout(FlowLayout.LEFT));
  p7.add(male);
  p7.add(female);
  add(p7);
 
   
  p8=new Panel();
 
  lst=new List(5);
  lst.add("ghatlodiya");
  lst.add("ranip");
  lst.add("bopal");
  l8=new Label("Address");
  p8.setLayout(new FlowLayout(FlowLayout.LEFT));
  p8.add(l8);
  p8.add(lst);
  add(p8);
 
  p9=new Panel();
  l9=new Label("City                ");
  tf9=new TextField(10);
  p9.setLayout(new FlowLayout(FlowLayout.LEFT));
  p9.add(l9);
  p9.add(tf9);
  add(p9);
 
  p10=new Panel();
  l10=new Label("Pin Code      ");  
  tf10=new TextField(10);
  p10.setLayout(new FlowLayout(FlowLayout.LEFT));
  p10.add(l10);
  p10.add(tf10);
  add(p10);
 
  p11=new Panel();
  l11=new Label("State             ");
  tf11=new TextField(10);
  p11.setLayout(new FlowLayout(FlowLayout.LEFT));
  p11.add(l11);
  p11.add(tf11);
  add(p11);
 
  p12=new Panel();
  l12=new Label("Country         ");
  tf12=new TextField(10);
  p12.setLayout(new FlowLayout(FlowLayout.LEFT));
  p12.add(l12);
  p12.add(tf12);
  add(p12);
 
  p13=new Panel();
  l13=new Label("Hobbies    ");
  c1=new Checkbox("reading");
  c2=new Checkbox("blogging");
  c3=new Checkbox("photography");
  c4=new Checkbox("other");
  p13.setLayout(new FlowLayout(FlowLayout.LEFT));
  p13.add(l13);
  p13.add(c1);
  p13.add(c2);
  p13.add(c3);
  p13.add(c4);
  add(p13);
 
  p14=new Panel();
  l14=new Label("Courses   ");
  p14.setLayout(new FlowLayout(FlowLayout.LEFT));
  p14.add(l14);
  add(p14);
 
   p15=new Panel();
  l15=new Label("Applies For  ");
  p15.setLayout(new FlowLayout(FlowLayout.LEFT));
  p15.add(l15);
  add(p15);
 
  p16=new Panel();
  cbg1=new CheckboxGroup();
  BE=new Checkbox(" BE",cbg,true);
  ME=new Checkbox(" ME",cbg,false);
  BCA=new Checkbox(" BCA",cbg,false);
  MCA=new Checkbox(" MCA",cbg,false);
  p16.setLayout(new FlowLayout(FlowLayout.LEFT));
  p16.add(BE);
  p16.add(ME);
  p16.add(BCA);
  p16.add(MCA);
  add(p16);
 
  p17=new Panel();
  b1=new Button("Submit");
  b2=new Button("Reset");
  b3=new Button("Close");
  p17.add(b1);
  p17.add(b2);
  p17.add(b3);
  add(p17);
 
  a=new Panel();
  a.setLayout(new FlowLayout(FlowLayout.CENTER));
  a2=new Label("Form");
  ta1=new TextArea(2,30);
  a.add(a2);
  a.add(ta1);
  add(a);

 
  b1.addActionListener(this);
  b2.addActionListener(this);
  b3.addActionListener(this);
 
  ch1.addItemListener(this);
  ch2.addItemListener(this);
  ch3.addItemListener(this);
 
  male.addItemListener(this);
  female.addItemListener(this);
  BE.addItemListener(this);
  ME.addItemListener(this);
  BCA.addItemListener(this);
  MCA.addItemListener(this);
 
  c1.addItemListener(this);
  c2.addItemListener(this);
  c3.addItemListener(this);
  c4.addItemListener(this);
  lst.addItemListener(this);
 
  addWindowListener(new studentform.MyWindowAdapter());
 
 
 }
  public void itemStateChanged(ItemEvent ie)
  {
   sd1=ch1.getSelectedItem();
   sd2=ch2.getSelectedItem();
   sd3=ch3.getSelectedItem();
   sl=lst.getSelectedItem();
   if(ie.getSource()==male)
   {
    sb="male";
   }
   else
   {
    sb="female";  
   }
 
   if(ie.getSource()==BE)
   {
    sb1="BE";
   }
   else if(ie.getSource()==ME)
   {
    sb1="ME";  
   }  
   else if(ie.getSource()==BCA)
   {
    sb1="BCA";  
   }
   else if(ie.getSource()==MCA)
   {
    sb1="MCA";  
   }
 
 
   if(ie.getSource()==c1)
   {
    sc1="reading";
   }
   if(ie.getSource()==c2)
   {
    sc2="blogging";  
   }
   if(ie.getSource()==c3)
   {
    sc3="photography";  
   }
   if(ie.getSource()==c4)
   {
    sc4="other";  
   }
  }
 
 
  public void actionPerformed(ActionEvent ae)
  {
     
      st1=tf1.getText();
      st2=tf2.getText();
      st3=tf3.getText();
      st4=tf5.getText();
      st5=tf6.getText();
      st6=tf9.getText();
      st7=tf10.getText();
      st8=tf11.getText();
      st9=tf12.getText();
   
 
     
   if(ae.getSource()==b1)
   {
     ta1.setText(
                 "\nFull Name: "+st1 +" "+st2 +" "+st3
                +"\ndob:"+sd1 +"/"+sd2 +"/"+sd3          
                +"\nEmail: "+st4
                +"\nMobile no: "+st5
                +"\ngenger:"+sb
                +"\narea:"+sl
                +"\nCity: "+st6
                +"\nPin Code: "+st7
                +"\nState: "+st8
                +"\nCountry: "+st9
                +"\nHobbies:"+sc1 +","+sc2 +","+sc3 +","+sc4
                +"\nCourse:"+sb1
            );
   }
   if(ae.getSource()==b2)
   {
    tf1.setText("");
    tf2.setText("");
    tf3.setText("");
    tf5.setText("");
    tf6.setText("");
    tf9.setText("");
    tf10.setText("");
    tf11.setText("");
    tf12.setText("");
   

   
   
 
   }  
 
   if(ae.getSource()==b3)
    {
        System.exit(0);
    }
 
  }
 
 

  public static void main(String[] args)
  {
   new studentform();
  }
 
  class MyWindowAdapter extends WindowAdapter
  {
   public void windowClosing(WindowEvent we)
   {
    System.exit(0);
   }
  }

}