Advertisement
Guest User

Untitled

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