abhishekgidde

Registration Class

Sep 19th, 2017
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.46 KB | None | 0 0
  1. package com.abby;
  2. import javax.swing.*;
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import java.sql.*;
  6. import javax.swing.JButton;
  7. import javax.swing.JFrame;
  8. import javax.swing.JLabel;
  9. import javax.swing.JPanel;
  10. class Registration extends JFrame implements ActionListener
  11. {
  12.     JLabel l1, l2, l3, l4, l5, l6, l7, l8,stud1,stud2,stud3,stud4,stud5,stud6;
  13.     JTextField tf1, tf2, tf5, tf6, tf7;
  14.     JButton btn1, btn2 ;
  15.     JPasswordField p1, p2;
  16.  
  17.  
  18.     Registration()
  19.     {
  20.         setVisible(true);
  21.         setSize(700, 700);
  22.         setLayout(null);
  23.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  24.         setTitle("Registration Form");
  25.  
  26.         l1 = new JLabel("Student Registration Form:");
  27.         l1.setForeground(Color.blue);
  28.         l1.setFont(new Font("Algerian", Font.BOLD, 20));
  29.  
  30.         l2 = new JLabel("Name:");
  31.         l3 = new JLabel("Email-ID:");
  32.         l4 = new JLabel("Create Passowrd:");
  33.         l5 = new JLabel("Confirm Password:");
  34.         l6 = new JLabel("Country:");
  35.         l7 = new JLabel("State:");
  36.         l8 = new JLabel("Phone No:");
  37.         tf1 = new JTextField();
  38.         tf2 = new JTextField();
  39.         p1 = new JPasswordField();
  40.         p2 = new JPasswordField();
  41.         tf5 = new JTextField();
  42.         tf6 = new JTextField();
  43.         tf7 = new JTextField();
  44.  
  45.         btn1 = new JButton("Submit");
  46.         btn2 = new JButton("Clear");
  47.  
  48.  
  49.         btn1.addActionListener(this);
  50.         btn2.addActionListener(this);
  51.  
  52.         l1.setBounds(100, 30, 400, 30);
  53.         l2.setBounds(80, 70, 200, 30);
  54.         l3.setBounds(80, 110, 200, 30);
  55.         l4.setBounds(80, 150, 200, 30);
  56.         l5.setBounds(80, 190, 200, 30);
  57.         l6.setBounds(80, 230, 200, 30);
  58.         l7.setBounds(80, 270, 200, 30);
  59.         l8.setBounds(80, 310, 200, 30);
  60.         tf1.setBounds(300, 70, 200, 30);
  61.         tf2.setBounds(300, 110, 200, 30);
  62.         p1.setBounds(300, 150, 200, 30);
  63.         p2.setBounds(300, 190, 200, 30);
  64.         tf5.setBounds(300, 230, 200, 30);
  65.         tf6.setBounds(300, 270, 200, 30);
  66.         tf7.setBounds(300, 310, 200, 30);
  67.         btn1.setBounds(50, 350, 100, 30);
  68.         btn2.setBounds(170, 350, 100, 30);
  69.  
  70.         add(l1);
  71.         add(l2);
  72.         add(tf1);
  73.         add(l3);
  74.         add(tf2);
  75.         add(l4);
  76.         add(p1);
  77.         add(l5);
  78.         add(p2);
  79.         add(l6);
  80.         add(tf5);
  81.         add(l7);
  82.         add(tf6);
  83.         add(l8);
  84.         add(tf7);
  85.         add(btn1);
  86.         add(btn2);
  87.     }
  88.  
  89.     public void actionPerformed(ActionEvent e)
  90.     {
  91.         if (e.getSource() == btn1)
  92.         {
  93.             int x = 0;
  94.             String s1 = tf1.getText();
  95.             String s2 = tf2.getText();
  96.  
  97.             char[] s3 = p1.getPassword();
  98.             char[] s4 = p2.getPassword();
  99.             String s8 = new String(s3);
  100.             String s9 = new String(s4);
  101.  
  102.             String s5 = tf5.getText();
  103.             String s6 = tf6.getText();
  104.             String s7 = tf7.getText();
  105.             if (s8.equals(s9))
  106.             {
  107.                 try
  108.                 {
  109.                    /* Class.forName("oracle.jdbc.driver.OracleDriver");
  110.                     Connection con = DriverManager.getConnection("jdbc:oracle:thin:@mcndesktop07:1521:xe", "sandeep", "welcome");
  111.                     PreparedStatement ps = con.prepareStatement("insert into reg values(?,?,?,?,?,?)");
  112.                     ps.setString(1, s1);
  113.                     ps.setString(2, s2);
  114.                     ps.setString(3, s8);
  115.                     ps.setString(4, s5);
  116.                     ps.setString(5, s6);
  117.                     ps.setString(6, s7);
  118.                     ResultSet rs = ps.executeQuery();*/
  119.                     stud1= new JLabel("Hello ! "+s1);
  120.                    stud1.setBounds(100, 30, 400, 30);
  121.                     /*stud2.setBounds(100, 70, 400, 30);
  122.                     stud3.setBounds(100, 110, 400, 30);
  123.                     stud4.setBounds(100, 150, 400, 30);
  124.                     stud5.setBounds(100, 190, 400, 30);
  125.                     stud6.setBounds(100, 230, 400, 30);*/
  126.                     l2 = new JLabel("");
  127.                     l3 = new JLabel("");
  128.                     l4 = new JLabel("");
  129.                     l5 = new JLabel("");
  130.                     l6 = new JLabel("");
  131.                     l7 = new JLabel("");
  132.                     l8 = new JLabel("");
  133.                     tf1 = new JTextField();
  134.                     tf2 = new JTextField();
  135.                     p1 = new JPasswordField();
  136.                     p2 = new JPasswordField();
  137.                     tf5 = new JTextField();
  138.                     tf6 = new JTextField();
  139.                     tf7 = new JTextField();
  140.                     x++;
  141.                     if (x > 0)
  142.                     {
  143.                         JOptionPane.showMessageDialog(btn1, "Data Saved Successfully");
  144.                     }
  145.                 }
  146.                 catch (Exception ex)
  147.                 {
  148.                     System.out.println(ex);
  149.                 }
  150.             }
  151.             else
  152.             {
  153.                 JOptionPane.showMessageDialog(btn1, "Password Does Not Match");
  154.             }
  155.         }
  156.         else
  157.         {
  158.             tf1.setText("");
  159.             tf2.setText("");
  160.             p1.setText("");
  161.             p2.setText("");
  162.             tf5.setText("");
  163.             tf6.setText("");
  164.             tf7.setText("");
  165.         }
  166.     }
  167.    /* public static void Main(String args[])
  168.     {
  169.         new Registration();
  170.     }
  171. */
  172. }
Add Comment
Please, Sign In to add comment