-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSignup.java
179 lines (141 loc) · 5.78 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
package travel_and_Tourism_Organisation_System;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
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(340,200,700,407);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setBackground(Color.WHITE);
//contentPane.setBackground(new Color(255,230,230 ));
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);
ImageIcon c1 = new ImageIcon(ClassLoader.getSystemResource("travel_and_Tourism_Organisation_System/icons/signup.png"));
Image i1 = c1.getImage().getScaledInstance(200, 200,Image.SCALE_DEFAULT);
ImageIcon i2 = new ImageIcon(i1);
JLabel l6 = new JLabel(i2);
l6.setBounds(460, 90, 200, 200);
add(l6);
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); //255,230,230
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(255,204,204), 2),"",
TitledBorder.LEADING, TitledBorder.TOP, null, new Color(34, 139, 34)));
panel.setBounds(31,30, 640, 300);
//panel.setBackground(Color.WHITE);
panel.setBackground(new Color(255,204,204));
contentPane.add(panel);
}
public void actionPerformed(ActionEvent ae){
try{
Conn con = new Conn();
if(ae.getSource() == b1){
if(textField.getText().equals("") || textField_1.getText().equals("") || textField_2.getText().equals("") || textField_3.getText().equals("")) {
JOptionPane.showMessageDialog(null, "Sorry! Can't create account! ");
}
else {
String sql = "insert into account(username, name, password, security, answer) 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, "Account Created Successfully ");
}
textField.setText("");
textField_1.setText("");
textField_2.setText("");
textField_3.setText("");
}
this.setVisible(false);
new Login().setVisible(true);
}
if(ae.getSource() == b2){
this.setVisible(false);
new Login().setVisible(true);
}
}catch(Exception e){
System.out.println(e);
}
}
}