-
Notifications
You must be signed in to change notification settings - Fork 0
/
Signup.java
144 lines (119 loc) · 4.6 KB
/
Signup.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import java.awt.*;
import javax.swing.*;
import java.sql.*;
import java.awt.event.*;
import javax.swing.border.*;
public class Signup extends JFrame implements ActionListener{
private JPanel contentPane;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
private JTextField textField_3;
private JButton b1, b2;
private JComboBox comboBox;
public static void main(String[] args) {
new Signup().setVisible(true);
}
public Signup() {
setBounds(600, 250, 606, 406);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setBackground(Color.WHITE);
contentPane.setLayout(null);
JLabel lblUsername = new JLabel("Username :");
lblUsername.setForeground(Color.DARK_GRAY);
lblUsername.setFont(new Font("Tahoma", Font.BOLD, 14));
lblUsername.setBounds(99, 86, 92, 26);
contentPane.add(lblUsername);
JLabel lblName = new JLabel("Name :");
lblName.setForeground(Color.DARK_GRAY);
lblName.setFont(new Font("Tahoma", Font.BOLD, 14));
lblName.setBounds(99, 123, 92, 26);
contentPane.add(lblName);
JLabel lblPassword = new JLabel("Password :");
lblPassword.setForeground(Color.DARK_GRAY);
lblPassword.setFont(new Font("Tahoma", Font.BOLD, 14));
lblPassword.setBounds(99, 160, 92, 26);
contentPane.add(lblPassword);
JLabel lblAnswer = new JLabel("Answer :");
lblAnswer.setForeground(Color.DARK_GRAY);
lblAnswer.setFont(new Font("Tahoma", Font.BOLD, 14));
lblAnswer.setBounds(99, 234, 92, 26);
contentPane.add(lblAnswer);
comboBox = new JComboBox();
comboBox.setModel(new DefaultComboBoxModel(new String[] { "Your NickName?", "Your Lucky Number?",
"Your child SuperHero?", "Your childhood Name ?" }));
comboBox.setBounds(265, 202, 148, 20);
contentPane.add(comboBox);
JLabel lblSecurityQuestion = new JLabel("Security Question :");
lblSecurityQuestion.setForeground(Color.DARK_GRAY);
lblSecurityQuestion.setFont(new Font("Tahoma", Font.BOLD, 14));
lblSecurityQuestion.setBounds(99, 197, 140, 26);
contentPane.add(lblSecurityQuestion);
textField = new JTextField();
textField.setBounds(265, 91, 148, 20);
contentPane.add(textField);
textField.setColumns(10);
textField_1 = new JTextField();
textField_1.setColumns(10);
textField_1.setBounds(265, 128, 148, 20);
contentPane.add(textField_1);
textField_2 = new JTextField();
textField_2.setColumns(10);
textField_2.setBounds(265, 165, 148, 20);
contentPane.add(textField_2);
textField_3 = new JTextField();
textField_3.setColumns(10);
textField_3.setBounds(265, 239, 148, 20);
contentPane.add(textField_3);
b1 = new JButton("Create");
b1.addActionListener(this);
b1.setFont(new Font("Tahoma", Font.BOLD, 13));
b1.setBounds(140, 289, 100, 30);
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
contentPane.add(b1);
b2 = new JButton("Back");
b2.addActionListener(this);
b2.setFont(new Font("Tahoma", Font.BOLD, 13));
b2.setBounds(300, 289, 100, 30);
b2.setBackground(Color.BLACK);
b2.setForeground(Color.WHITE);
contentPane.add(b2);
JPanel panel = new JPanel();
panel.setForeground(new Color(34, 139, 34));
panel.setBorder(new TitledBorder(new LineBorder(new Color(128, 128, 0), 2), "Create-Account",
TitledBorder.LEADING, TitledBorder.TOP, null, new Color(34, 139, 34)));
panel.setBounds(31, 46, 476, 296);
panel.setBackground(Color.WHITE);
contentPane.add(panel);
}
public void actionPerformed(ActionEvent ae){
try{
conn con = new conn();
if(ae.getSource() == b1){
String sql = "insert into account(username, name, password, sec_q, sec_ans) values(?, ?, ?, ?, ?)";
PreparedStatement st = con.c.prepareStatement(sql);
st.setString(1, textField.getText());
st.setString(2, textField_1.getText());
st.setString(3, textField_2.getText());
st.setString(4, (String) comboBox.getSelectedItem());
st.setString(5, textField_3.getText());
int i = st.executeUpdate();
if (i > 0){
JOptionPane.showMessageDialog(null, "successfully Created");
}
textField.setText("");
textField_1.setText("");
textField_2.setText("");
textField_3.setText("");
}
if(ae.getSource() == b2){
this.setVisible(false);
new Login_user().setVisible(true);
}
}catch(Exception e){
}
}
}