-
Notifications
You must be signed in to change notification settings - Fork 0
/
Login_user.java
119 lines (96 loc) · 3.27 KB
/
Login_user.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
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
public class Login_user extends JFrame implements ActionListener{
private JPanel panel;
private JTextField textField;
private JPasswordField passwordField;
private JButton b1,b2,b3;
public Login_user() {
//setBackground(new Color(204,204,255));
setBounds(600, 300, 600, 400);
panel = new JPanel();
panel.setBackground(new Color(204,204,255));
setContentPane(panel);
panel.setLayout(null);
JLabel l1 = new JLabel("Username : ");
l1.setBounds(124, 89, 95, 24);
panel.add(l1);
JLabel l2 = new JLabel("Password : ");
l2.setBounds(124, 124, 95, 24);
panel.add(l2);
textField = new JTextField();
textField.setBounds(210, 93, 157, 20);
panel.add(textField);
passwordField = new JPasswordField();
passwordField.setBounds(210, 128, 157, 20);
panel.add(passwordField);
JLabel l3 = new JLabel("");
l3.setBounds(377, 79, 46, 34);
panel.add(l3);
JLabel l4 = new JLabel("");
l4.setBounds(377, 124, 46, 34);
panel.add(l3);
b1 = new JButton("Login");
b1.addActionListener(this);
b1.setForeground(Color.WHITE);
b1.setBackground(Color.black);
b1.setBounds(149, 181, 113, 39);
panel.add(b1);
b2 = new JButton("SignUp");
b2.addActionListener(this);
b2.setForeground(Color.white);
b2.setBackground(Color.black);
b2.setBounds(289, 181, 113, 39);
panel.add(b2);
b3 = new JButton("Forgot Password");
b3.addActionListener(this);
b3.setForeground(new Color(205, 92, 92));
b3.setBackground(new Color(253, 245, 230));
b3.setBounds(199, 231, 179, 39);
panel.add(b3);
JLabel l5 = new JLabel("Trouble in Login?");
l5.setFont(new Font("Tahoma", Font.PLAIN, 15));
l5.setForeground(new Color(255, 0, 0));
l5.setBounds(70, 240, 130, 20);
panel.add(l5);
JPanel panel2 = new JPanel();
panel2.setBackground(new Color(204,204,255));
panel2.setBounds(24, 40, 434, 263);
panel.add(panel2);
}
public void actionPerformed(ActionEvent ae){
if(ae.getSource() == b1){
Boolean status = false;
try {
conn con = new conn();
String sql = "select * from account where username=? and password=?";
PreparedStatement st = con.c.prepareStatement(sql);
st.setString(1, textField.getText());
st.setString(2, passwordField.getText());
ResultSet rs = st.executeQuery();
if (rs.next()) {
this.setVisible(false);
new Loading().setVisible(true);
} else
JOptionPane.showMessageDialog(null, "Invalid Login...!.");
} catch (Exception e2) {
e2.printStackTrace();
}
}
if(ae.getSource() == b2){
setVisible(false);
Signup su = new Signup();
su.setVisible(true);
}
if(ae.getSource() == b3){
setVisible(false);
Forgot forgot = new Forgot();
forgot.setVisible(true);
}
}
public static void main(String[] args) {
new Login_user().setVisible(true);
}
}